S = input() n = len(S) pal = [[0]*(n+1) for i in range(n+1)] for i in range(n): l = i r = i while l >= 0 and r < n and S[l] == S[r]: pal[l][r+1] = 1 l -= 1 r += 1 l = i r = i+1 while l >= 0 and r < n and S[l] == S[r]: pal[l][r+1] = 1 l -= 1 r += 1 dp = [-1]*(n+1) dp[0] = n+1 for i in range(n): if dp[i] == -1: continue for j in range(i+1,n+1): if pal[i][j]: dp[j] = max(dp[j],min(dp[i],j-i)) print(dp[-1])