#include using namespace std; vector manacher(string s){ int i = 0, j = 0; vector res(s.size()); while (i < s.size()) { while (i - j >= 0 && i + j < s.size() && s[i - j] == s[i + j]) ++j; res[i] = j; int k = 1; while (i - k >= 0 && i + k < s.size() && k + res[i - k] < j) res[i + k] = res[i - k], ++k; i += k; j -= k; } return res; } int main(){ int n, ans = 0; string s; cin >> s; n = s.size(); string t = "$"; for(int i = 0; i < s.size(); i++){ t += s[i]; t += "$"; } s = t; vector len = manacher(s), left(s.size()), right(s.size()); for(int i = 0; i < len.size(); i++){ len[i]--; if(len[i] != n) ans = max(ans, len[i]); else ans = n - 1; } cout << ans << endl; }