while True:
    try:
        s = input()
        n = len(s)
        if n < 2:
            print(n)
        else:
            dp = [[False] * n for _ in range(n)]
            for i in range(n):
                dp[i][i] = True
            Max = 1
            for l in range(2, n+1):
                for i in range(n):
                    j = i + l - 1
                    if j >= n:
                        break
                    if s[i] != s[j]:
                        dp[i][j] = False
                    else:
                        if j - i < 3:
                            dp[i][j] = True
                        else:
                            dp[i][j] = dp[i+1][j-1]
                    if dp[i][j] and j + 1 - i > Max:
                        Max = j + 1 - i
            print(Max)
    except:
        break