import sys

def main():
    s = input().strip()
    t = s[::-1]
    n = len(s)
    if s == t:
        print(n)
        return

    dp = [[False for _ in range(n)] for _ in range(n)]
    for i in range(n):
        dp[i][i] = True
    for i in range(n-1):
        if s[i] == s[i+1]:
            dp[i][i+1] = True

    ret = 1
	# [i..j]的判断依赖于[i+1..j-1],所以按字符串长度从小到大遍历
    for L in range(3, n+1):
        for i in range(n-L+1):
            j = i+L-1
            if s[i] == s[j]:
                dp[i][j] = dp[i+1][j-1]
            if dp[i][j] and j-i+1>ret:
                ret = j-i+1
    print(ret)
    
main()