def manacher(s): # Preprocess the string to handle even and odd length palindromes uniformly T = '#'.join('^{}$'.format(s)) n = len(T) P = [0] * n # Array to store the length of the palindrome centered at each position C = R = 0 # Center and right boundary of the current palindrome max_len = 0 # Maximum length of the palindrome found for i in range(1, n - 1): # Mirror of i with respect to C mirror = 2 * C - i # Check if the current position is within the right boundary if i < R: P[i] = min(R - i, P[mirror]) # Expand around the current center while T[i + P[i] + 1] == T[i - P[i] - 1]: P[i] += 1 # Update the center and right boundary if the expanded palindrome exceeds the current boundary if i + P[i] > R: C, R = i, i + P[i] # Update the maximum length found if P[i] > max_len: max_len = P[i] return max_len s = input().strip() if s == s[::-1]: print(len(s) - 1) else: print(manacher(s))