Palindrome#1999

Palindrome

1 second
128 megabytes
Hard

You are given a non-empty string consisting of lowercase Latin letters. You are allowed to add characters to the beginning and the end of the string. Add the minimum number of characters to obtain a palindrome.

Recall that a palindrome is a string that reads the same forwards and backwards.

Input

A single string consisting of lowercase Latin letters. The length of the string is from to 10^6 characters.

Output

Print the minimum number of characters that must be added to the original string to obtain a palindrome.

Examples

Example 1

Loading
Loading