#include"iostream"
#include"stdio.h"
using namespace std;
const int maxn=3e6+5;
int P[maxn];
int f(string ss)
{
int ans=-1;
string s("#");
for(int i=0;ss[i];i++)
{
s+=ss[i];
s+="#";
}
P[0]=1;
int id=1,mx=1;
for(int i=1;s[i];i++)
{
if(mx>i)
{
P[i]=min(P[id*2-i],mx-i);
}
else
{
P[i]=1;
}
while(s[i-P[i]]==s[i+P[i]]&&s[i-P[i]]&&s[i+P[i]])P[i]++;
if(i+P[i]>=mx)
{
mx=i+P[i];
id=i;
}
ans=max(ans,P[i]-1);
}
return ans;
}
int main()
{
string s;
// freopen("a.txt","r",stdin);
// freopen("1.txt","a",stdout);
while(cin>>s)
{
cout<<f(s)<<"\n";
}
}