// The Difference
#include <bits/stdc++.h>
using namespace std;
int LPS(string str, int n)
{
int longest_p = 1;
vector<vector<int>> dp(n, vector<int>(n, 0));
for (int g = 0; g < n; g++)
{
for (int i = 0, j = g; j < n; i++, j++)
{
if (g == 0)
dp[i][j] = 1;
else if (g == 1)
{
if (str[i] == str[j])
{
dp[i][j] = 1;
longest_p = max(longest_p, j - i + 1);
}
}
else
{
if (str[i] == str[j] && dp[i + 1][j - 1])
{
dp[i][j] = 1;
longest_p = max(longest_p, j - i + 1);
}
}
}
}
return longest_p;
}
int main()
{
string str;
cin >> str;
int n = str.size();
if (n == 0 || n == 1)
cout << 0 << endl;
else
cout << LPS(str, n) - 1 << endl;
return 0;
}