Problem list
Log in
#r03522 · CCC 2016 Junior

Hidden Palindrome

Bronze I 2.0 s 256 MB

A palindrome is a word which is the same when read forwards as it is when read backwards. For example, mom and anna are two palindromes.

A word which has just one letter, such as a, is also a palindrome.

Given a word, what is the longest palindrome that is contained in the word? That is, what is the longest palindrome that we can obtain, if we are allowed to delete characters from the beginning and/or the end of the string?

Input

The input will consist of one line, containing a sequence of at least 1 and at most 40 lowercase letters.

Output

Output the total number of letters of the longest palindrome contained in the input word.

Example 1

Input
banana
Output
5

The palindrome anana has 5 letters.

Example 2

Input
abracadabra
Output
3

The palindromes aca and ada have 3 letters, and there are no other palindromes in the input which are longer.

Example 3

Input
abba
Output
4
Source
CCC 2016 Junior
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code