def longest_palindrome(s):
def expand_around_center(left, right):
# 从中心向两边扩展
while left >= 0 and right < len(s) and s[left] == s[right]:
left -= 1
right += 1
# 返回扩展后的回文子串的长度
return right - left - 1
start, end = 0, 0
for i in range(len(s)):
# 以 s[i] 为中心的最长回文子串
len1 = expand_around_center(i, i)
# 以 s[i] 和 s[i+1] 为中心的最长回文子串
len2 = expand_around_center(i, i + 1)
# 取两者之间的最大值
max_len = max(len1, len2)
if max_len > end - start:
start = i - (max_len - 1) // 2
end = i + max_len // 2
# 最长回文子串的长度
return end - start + 1
# 输入字符串
s = input()
# 输出最长有效密码串的长度
print(longest_palindrome(s))