#include <iostream> #include <vector> using namespace std; int main() { string str; while (cin >> str) { int n = str.size(); int maxD = 1; vector<vector<bool>> dp(n,vector<bool>(n, false)); for (int i = n-1; i >= 0; --i) { for (int j = i+1; j < n; ++j) { if (j-i<=2) dp[i][j] = str[i]==str[j]; else dp[i][j] = str[i]==str[j]&&dp[i+1][j-1]; if (dp[i][j]) maxD = max(maxD,j-i+1); } } cout<<maxD<<endl; } }