#include using namespace std; using ll = long long; const ll MOD1=1e9+7, BASE1=272783711; const ll MOD2=999999937, BASE2=483283287; template struct RollingHash{ int N; vector hash, bpow; RollingHash(const vector &v) {init(v);} void init(vector &v){ N = v.size(); hash.resize(N+1); bpow.resize(N+1); bpow[0] = 1; for (int i=0; i v(s.begin(), s.end()); init(v); } //0-indexed (Hash of S[l:r]) ll get(ll l, ll r){ r++; return (hash[r]+MOD-(hash[l]*bpow[r-l])%MOD) % MOD; } }; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; string S, T; cin >> S; T = S; N = S.size(); reverse(T.begin(), T.end()); RollingHash rh1(S), rh2(T); //Is S[l:r] palindrome? auto f=[&](int l, int r)->bool{ int len=r-l+1; return rh1.get(l, l+len/2-1) == rh2.get(N-1-r, N-1-(r-len/2+1)); }; vector dp(N+1); dp[0] = 1e9; for (int i=1; i<=N; i++){ for (int j=1; j<=i; j++){ if (f(j-1, i-1)) dp[i] = max(dp[i], min(dp[j-1], i-j+1)); } } cout << dp[N] << endl; return 0; }