s = input() n = len(s) ok = [[False for _ in range(n + 1)] for _ in range(n + 1)] for i in range(n): ok[i + 1][i + 1] = True if i < n - 1 and s[i] == s[i + 1]: ok[i + 1][i + 2] = True for d in range(3, n + 1): for l in range(n + 1 - d): r = l + d - 1 if ok[l + 2][r] and s[l] == s[r]: ok[l + 1][r + 1] = True dp = [0 for _ in range(n + 1)] dp[0] = 1 << 60 dp[1] = 1 for r in range(2, n + 1): for l in range(r): if ok[l + 1][r]: dp[r] = max(dp[r], min(dp[l], r - l)) print(dp[-1])