import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### s = input() n = len(s) dp = [[0 for j in range(n+1)]for i in range(n)] for i in range(n): dp[i][i+1] = 1 dp[i][i] = 1 for d in range(2,n+1): for i in range(n-d+1): j = i + d if s[i] == s[j-1]: dp[i][j] = dp[i+1][j-1] ans = [0] * (n+1) ans[0] = 10**9 for i in range(n): for j in range(i+1, n+1): if dp[i][j]: ans[j] = max(ans[j], min(ans[i], j-i)) print(ans[n])