#include #include #include #include #include #include #include #include #include #include #include using namespace std; int N; string S; vector> ok; bool solve(int x){ int prev = 0; for (int i=1; i<=N; i++){ if (ok[prev+1][i] && i-prev>=x) prev = i; } return (N == prev); } int main(){ int l, r, c; cin >> S; assert(S.size() <= 5000); for (auto x : S) assert('a' <= x && x <= 'z'); N = S.size(); ok.resize(N+1, vector(N+1)); for (int i=N; i>=1; i--){ for (int j=i; j<=N; j++){ ok[i][j] = (S[i-1] == S[j-1]); if (i+1 <= j-1) ok[i][j] = (ok[i][j] & ok[i+1][j-1]); } } l = 1, r = N+1; while(r-l > 1){ c = (r+l) / 2LL; if (solve(c)) l = c; else r = c; } cout << l << endl; return 0; }