#include "bits/stdc++.h"
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define OPEN freopen (".in", "r", stdin); freopen (".out", "w", stdout);
#define pc __builtin_popcount
#define db double
#define pii pair<int, int>
#define fi first
#define se second
#define F(i,x,y) for (int i = (x); i <= (y); ++i)
#define D(i,x,y) for (int i = (x); i >= (y); --i)
using namespace std;
const ll inf = 1ll * 1e18;
//const ll mod = 998244353ll;
const ll mod = 1ll * 1e9 + 7ll;
inline void Rd(int& x) {
int f = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c - 48), c = getchar();
x *= f;
}
inline void Wt(int x) {
if (x < 10) {
putchar(x + 48);
return;
}
Wt(x / 10);
putchar((x % 10) + 48);
}
bool st;
int d[33000020];
string s, t;
int n;
bool ed;
int ans;
int main() {
cerr << (&st - &ed) / 1024.0 / 1024.0 << '\n';
cin >> s; s = ' ' + s;
F(i, 1, s.size() - 1) {
t += '#';
t += s[i];
}
t += '#'; n = t.size() - 1;
cerr << t << ' ' << n <<'\n';
int mx = 1;
d[0] = 1; d[1] = 2;
int r = 0;
F(i, 2, n - 1) {
r = mx + d[mx] - 1;
// if (i > r) continue ;
int mn = min(r - i + 1, d[2 * mx - i]);
// cerr << i << ':' << d[2 * mx - i] << ' ' << r - i + 1 << '\n';
// cerr << r << ' ' << 2 * mx - i << ' ' << mn << ' ' << mx << '\n';
int j, k;
for (j = i - mn + 1, k = i + mn - 1; j >= 0 && k < n && t[j] == t[k]; -- j, ++ k) ;
// cerr << j << ' ' << k << ' ' << t[j] << ' ' << t[k] << '\n';
d[i] = i - j;
if (i + d[i] - 1 > mx) mx = i;
ans = max(ans, d[i]);
}
// F(i, 1, n) cerr << d[i] << ' '; cerr << '\n';
cout << ans - 1;
}
#4 TLE,WA 了三个点(#8,#11,#15)。
