DWITE
October 2011
Problem 5
Tattarrattat

A palindrome is a word that is the same backwards as it is forwards (e.g. tattarrattat). Even though most words aren't palindromes, you can always remove letters from the word to make it a palindrome (remember that all words of length 0 or 1 are palindromes). For example, "farmer" is not a palindrome, but removing a few letters yields "rer", which is a palindrome.

Your task is to determine the length of the longest palindrome you can get from a word by removing zero or more letters.

The input file DATA5.txt will contain 5 test cases, each a line with a string S consisting of no more than 255 alphanumeric characters (a-z, A-Z, 0-9). There are no spaces.

The output file OUT5.txt will contain 5 lines of output, each a number — the length of the longest palindrome you can get by removing zero or more letters from the corresponding string.

Sample Input (first 3 shown):
 
tattarrattat
sounds
cool
		        
Sample Output (first 3 shown):
 
12
3
2