int n; char s[maxn], c[maxn << 1]; int l[maxn << 1], r[maxn << 1], ans; int f[maxn << 1];
voidmanacher(){ int mx = 0, id = 0; int ptr = 0; c[++ptr] = '#'; for (int i = 1; i <= n; ++i) { c[++ptr] = s[i]; c[++ptr] = '#'; } for (int i = 1; i <= ptr; ++i) { if (mx > i) f[i] = min(f[2 * id - i], mx - i); else f[i] = 1; while (c[i + f[i]] == c[i - f[i]]) f[i]++; if (i + f[i] > mx) mx = i + f[i], id = i; r[i + f[i] - 1] = max(r[i + f[i] - 1], f[i] - 1); l[i - f[i] + 1] = max(l[i - f[i] + 1], f[i] - 1); } n = ptr; }
intmain(){ scanf("%s", s + 1); n = strlen(s + 1); manacher(); for (int i = 3; i <= n; i += 2) { l[i] = max(l[i], l[i - 2] - 2); } for (int i = n; i >= 1; i -= 2) { r[i] = max(r[i], r[i + 2] - 2); } for (int i = 1; i <= n; i += 2) if (l[i] && r[i]) ans = max(ans, l[i] + r[i]); printf("%d\n", ans); return0; }