# a1 = '12HHHHA24'
# a2 = '42AHHHH21'
# b1 = '12ABBA24'
# b2 = '42ABBA21'
# c1 = 'ABAKK'
# c2 = 'KKABA'
# 由上规律可得:对称的字符串你正序和逆序是一致的,则只要截取遍历正序,找到在逆序中也存在的最长子串即可
s = input()
n = len(s)
arr = []
for i in range(n - 1):
    for j in range(1, n):
        if s[i] == s[j] and s[i+1:j] == s[j-1:i:-1]:
            arr.append(j+1-i)
print(max(arr))