while True:
try:
s = input()
L = len(s)
if L < 2:
print(L)
# 初始化二维数组dp
dp = [[False] * L for _ in range(L)]
# 单个字符一定是回文
for i in range(L):
dp[i][i] = True
Max = 1
# 枚举长度,从2开始
for n in range(2, L+1):
# 枚举左侧下标i:0~L-1
for i in range(L):
# 右侧下标j:j-i+1 = n -> j = n - 1 + i
j = n - 1 + i
# 如果右侧下标超出范围,跳出循环
if j >= L:
break
if s[i] != s[j]:
dp[i][j] = False
else:
# 如果子串长度为2或3,一定是回文
if j - i < 3:
dp[i][j] = True
else:
dp[i][j] = dp[i+1][j-1]
# 如果字串回文,判断长度是否大于Max
if dp[i][j] and j - i + 1 > Max:
Max = j - i + 1
print(Max)
except:
break