#include <bits/stdc++.h>
using namespace std;
string s;
bool is_hui(int x, int y)
{
while(x < y)
{
if(s[x] != s[y]) return false;
++ x, -- y;
}
return true;
}
int main()
{
getline(cin, s);
map<char,vector<int>> hash;
for(int i = 0; i < s.size(); ++ i)
hash[s[i]].push_back(i);
int res = 1;
for(auto hi : hash)
for(int i = 0; i < hi.second.size(); ++ i)
for(int j = i + 1; j < hi.second.size(); ++ j)
if(is_hui(hi.second[i], hi.second[j])) res = max(res, hi.second[j] - hi.second[i] + 1);
cout << res << endl;
return 0;
}