String
s of length
n is called
k-palindrome, if it is a palindrome itself, and its prefix and suffix of length
are
(k-1)-palindromes. By definition, any string (even empty) is 0-palindrome.
Let's call the palindrome degree of string
s such a maximum number
k, for which
s is
k-palindrome. For example, "
abaaba" has degree equals to
3.
You are given a string. Your task is to find the sum of the palindrome degrees of all its prefixes.