#include using namespace std; typedef long long ll; #define REP(i,n) for(int (i)=0;(i)<(n);++(i)) #define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i)) #define EACH(e,v) for(auto& e:v) #define ALL(v) (v).begin(),(v).end() #define SORT(v) sort(ALL(v)) #define RSORT(v) sort((v).rbegin(),(v).rend()) #define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v))) #define UNIQUE(v) SORT(v);(v).erase(unique(ALL(v)),(v).end()) template inline bool chmax(A &a,const B &b){if(a inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;} // #define int long const int MOD = (int)1e9 + 7; const int INF = 1 << 30; const ll INFF = 1LL << 62; // 下にy, 右にx enum {R, U, L, D}; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; template struct RollingHash { vector hsh, pwr; ll umod(ll n) { return (n % mod + mod) % mod; } RollingHash(const string &s) { int sz = (int)s.size(); hsh.assign(sz + 1, 0); pwr.assign(sz + 1, 0); pwr[0] = 1; for (int i = 0; i < sz; ++i) { hsh[i + 1] = umod(hsh[i] * base + s[i]); pwr[i + 1] = umod(pwr[i] * base); } } // [l, r) ll get(int l, int r) { return umod(hsh[r] - hsh[l] * pwr[r - l]); } // h1 <- h2 ll join(ll h1, ll h2, int h2_sz) { return umod(h1 * pwr[h2_sz] + h2); } }; using RH1 = RollingHash<(int)1e9 + 7>; using RH2 = RollingHash<(int)1e9 + 9>; using RH = pair; using H = pair; RH init(const string &s) { return make_pair(RH1(s), RH2(s)); } H get(RH &rh, int l, int r) { return make_pair(rh.first.get(l, r), rh.second.get(l, r)); } H join(RH &rh, ll h1, ll h2, int h2len) { return make_pair(rh.first.join(h1, h2, h2len), rh.second.join(h1, h2, h2len)); } signed main() { string S2; cin >> S2; int N2 = S2.size(); string S; for (int i = 0; i < N2; ++i) { S += S2[i]; if (i != N2 - 1) S += "a"; } int N = S.size(); string T(S); reverse(T.begin(), T.end()); RH S_rh = init(S); RH T_rh = init(T); // 中心cen, 腕の長さmが回文であるならtrue function check = [&](int cen, int m) { if (cen + m + 1 > N) return false; H s = get(S_rh, cen, cen + m + 1); int cen_rev = N - 1 - cen; if (cen_rev + m + 1 > N) return false; H t = get(T_rh, cen_rev, cen_rev + m + 1); return (s == t); }; ll res = 1; // i文字目を中心とする最長回文 for (int i = 0; i < N; i++) { ll ok = 0, ng = N; while (abs(ok - ng) > 1) { ll mid = (ok + ng) / 2; if (check(i, mid)) { ok = mid; } else { ng = mid; } } // iが奇数なら偶数長の回文 // iが偶数なら奇数長の回文 // chmax(res, ok); if (i % 2 == 0) chmax(res, ok + 1); else chmax(res, ok); } cout << min(N2 - 1, res) << endl; }