#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
using namespace std;
string str;
char s[2000005];
int p[2000005];
int main()
{
while(cin >> str)
{
int j = 1;
s[0] = '$';
for(int i = 0; str[i] != '\0'; i++)
{
s[j++] = '#';
s[j++] = str[i];
}
s[j++] = '#';
s[j] = '\0';
int id = 0, mx = 0, ans = -1;
for(int i = 1; s[i] != '\0'; i++)
{
p[i] = mx > i ? min(p[2 * id - i], mx - i) : 1;
while(s[i - p[i]] == s[i + p[i]])
{
p[i]++;
}
if(p[i] + i > mx)
{
mx = p[i] + i;
id = i;
}
ans = max(ans, p[i] - 1);
}
cout << ans << endl;
}
return 0;
}