A palindrome is a word that reads the same backwards as forwards. For example, a
, abba
, and
anavolimilovana
are palindromes. A sample is a string of one or more lowercase letters of the English
alphabet, and the weight of a sample is the number of its substrings (words) that are palindromes, counting
each word occurrence separately.
More precisely, let
You are given the sample
Input Specification
The first line of input contains the given sample
Output Specification
You must output the required maximal possible weight.
Constraints
Let
Subtask | Score | Constraints |
---|---|---|
Sample Input 1
aaaa
Sample Output 1
10
Explanation for Sample Output 1
Each substring from the sample already is a palindrome, so it is best left unchanged.
Sample Input 2
baccb
Sample Output 2
9
Explanation for Sample Output 2
If we change the second letter of the sample to c
, we will get the sample bcccb
with a weight of
Sample Input 3
slavko
Sample Output 3
7
Comments