#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; namespace pal { enum {even, odd, merge}; template < int type = odd > vector manacher(string s) { if(type == even || type == merge) { int n = int(s.size()); string t(2 * n - 1, '$'); for(int i = 0; i < n; i++) t[2 * i] = s[i]; swap(s, t); } int n = int(s.size()); vector R(n); for(int i = 0, j = 0, k; i < n; i += k, j -= k) { while(0 <= i - j && i + j < n && s[i - j] == s[i + j]) j++; R[i] = j; for(k = 1; 0 <= i - k && i + k < n && k + R[i - k] < j; k++) R[i + k] = R[i - k]; } if(type == odd) for(int i = 0; i < n; i++) R[i] = 2 * R[i] - 1; if(type == even) { for(int i = 1; i < n - 1; i += 2) R[i / 2] = R[i] - (!((i ^ R[i]) & 1)); for(int i = 0; i < n; i += 2) R.pop_back(); } if(type == merge) for(int i = 0; i < n; i++) if(!((i ^ R[i]) & 1)) R[i]--; return R; } } // namespace pal int main(){ cin.tie(0); ios::sync_with_stdio(0); string S; cin >> S; vector A = pal::manacher(S); cout << *max_element(A.begin(), A.end()) << endl; }