S = input() N = len(S) l = [[] for _ in range(N)] for i in range(N): delta = 0 while True: if i - delta >= 0 and i + delta < N: if S[i - delta] == S[i + delta]: l[i - delta].append(i + delta) else: break else: break delta += 1 delta = 0 while True: if i - delta >= 0 and i + 1 + delta < N: if S[i - delta] == S[i + delta + 1]: l[i - delta].append( i + 1 + delta) else: break else: break delta += 1 dp = [0] * (N + 1) dp[0] = 10 ** 6 for i in range(N): m = dp[i] for j in l[i]: t = min(m,j - i + 1) dp[j + 1] = max(dp[j + 1],t) print(dp[-1])