def longest_palindrome(s): # Transform s into T with special characters T = '#'.join('^{}$'.format(s)) n = len(T) P = [0] * n C = R = 0 max_len = 0 for i in range(1, n - 1): # Find the mirror of the current index mirror = 2 * C - i # Check if the current index is within the right boundary if i < R: P[i] = min(R - i, P[mirror]) # Attempt to expand palindrome centered at i while T[i + P[i] + 1] == T[i - P[i] - 1]: P[i] += 1 # Update the center and right boundary if the palindrome expands past R 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() n = len(s) if n == 0: print(0) else: L = longest_palindrome(s) if L == n: print(L - 1) else: print(L)