import sys 
for line in sys.stdin:
    s=line.strip()
    n = len(s)
    l = []
    for i in range(0,n-1):
        for j in range(1,n):
            if s[j] == s[i] and s[i+1:j] == s[j-1:i:-1]:
                l.append(len(s[i:j+1]))
    print(max(l))