#include<bits/stdc++.h> #define MAX_N 100000 #define MAX_M 200000 usingnamespace std; char s[MAX_M+5]; int n, f[MAX_M+5]; int L[MAX_N+5], R[MAX_N+5]; voidmanacher(){ int p = 0, r = 0; for (int i = 1; i <= n; i++) { f[i] = i < r ? min(f[p*2-i], r-i) : 1; while (i-f[i] >= 1 && i+f[i] <= n) if (s[i-f[i]] == s[i+f[i]]) f[i]++; elsebreak; if (i+f[i] > r) p = i, r = i+f[i]; } } intmain(){ char str[MAX_N+5]; scanf("%s", str), n = (int)strlen(str); for (int i = 0; i < n; i++) s[i*2+1] = '#', s[i*2+2] = str[i]; s[n = n*2+1] = '#', manacher(); int mx = 1, mi = n, ans = 0; for (int i = 1; i <= n; i++) if (f[i] > 1 && i+f[i] > mx) { for (int j = mx; j < i+f[i]; j++) L[j] = i; mx = i+f[i]; } for (int i = n; i >= 1; i--) if (f[i] > 1 && i-f[i] < mi) { for (int j = mi; j > i-f[i]; j--) R[j] = i; mi = i-f[i]; } for (int i = 1; i <= n; i++) ans = max(ans, R[i]-L[i]); returnprintf("%d\n", ans), 0; }