PRB9: Palindromesemordnilap // Beginner

 
Despite your recent success with geohashing, you’ve decided that it’s not quite enough. Rather than settle with taking the MD5 hashes straight from the Dow Jones opening, you want to find the shortest palindrome that containsthat MD5 hash and perform some more complicatedmangling. That’s a lot of tedious calculations, so you decide to write a program instead.

A string p is a palindrome if and only if, when the letters in p are reversed to form the string p’, p = p’. You want to output the length of the shortest palindromic string that has the input s as a contiguous substring.

Input Format

Line 1: a string s, consisting of n characters

Sample Input

ILOVECS

Output Format

Line 1: an integer m, indicating the number of characters in the shortest palindromic string p containing s

Sample Output

13




You must be logged in to submit a solution.