#include "iostream"
#include "string"
#include "sstream"
#include "vector"
#include "algorithm"
using namespace std;
int LongestPalindrome1(string s, int n)
{
int i, j, max, c;
if (s =="" || n < 1)
return 0;
max = 0;
for (i = 0; i < n; ++i) { // i is the middle point of the palindrome
for (j = 0; (i - j >= 0) && (i + j < n); ++j) { // if the length of the palindrome is odd
if (s[i - j] != s[i + j])
break;
c = j * 2 + 1;
}
if (c > max)
max = c;
for (j = 0; (i - j >= 0) && (i + j + 1 < n); ++j) { // for the even case
if (s[i - j] != s[i + j + 1])
break;
c = j * 2 + 2;
}
if (c > max)
max = c;
}
return max;
}
int LongestPalindrome2(string str)
{
int length = 0;
int max_len = 0;
int left = 0; int right = 0;
for (int i = 0; i < str.length(); i++)
{
//回文长度为奇数
length = 1;
left = i - 1;
right = i + 1;
while (left >= 0 && right < str.length() && str[left] == str[right])
{
length += 2;
left--;
right++;
}
if (length > max_len)
{
max_len = length;
}
//回文长度为偶数
length = 0;
left = i;
right = i + 1;
while (left >= 0 && right < str.length() && str[left] == str[right])
{
length += 2;
left--;
right++;
}
if (length > max_len)
max_len = length;
}
return max_len;
}
int main()
{
string str = "";
while (getline(cin, str))
{
int max_len = LongestPalindrome2(str);
cout << max_len << endl;
}
}