S = list(input()) N = len(S) ok = [[False] * N for _ in range(N)] for i in range(N): l = r = i while l >= 0 and r < N and S[l] == S[r]: ok[l][r] = True l -= 1 r += 1 l = i r = i + 1 while l >= 0 and r < N and S[l] == S[r]: ok[l][r] = True l -= 1 r += 1 INF = 10**9 dp = [0] * (N + 1) dp[0] = INF for i in range(1, N + 1): for j in range(i): if ok[j][i - 1]: dp[i] = max(dp[i], min(dp[j], i - j)) print(dp[N])