#K79907. Count Beautiful Substrings

    ID: 35412 Type: Default 1000ms 256MiB

Count Beautiful Substrings

Count Beautiful Substrings

You are given a string s consisting of digits. Your task is to count the number of "beautiful" substrings of s. A substring is considered beautiful if it is a palindrome, that is, it reads the same backward as forward. Note that each single character is a palindrome by itself.

Mathematically, a substring s[i...j] (with 0 ≤ i ≤ j < n, where n is the length of s) is a palindrome if it satisfies the equation:

\( s[i\dots j] = \mathtt{reverse}(s[i\dots j]) \)

Your program should read the input from standard input and print the result to standard output.

inputFormat

A single line containing a string consisting of digits. The string may be empty.

outputFormat

Output a single integer representing the total number of palindromic (beautiful) substrings.## sample

121
4