S = list(input()) N = len(S) ans = 0 for i in range(N): val = 1 left = i - 1 right = i + 1 while left >= 0 and right <= N - 1: if S[left] == S[right]: val += 2 left -= 1 right += 1 ans = max(ans, val) for i in range(N): val = 0 left = i - 1 right = i while left >= 0 and right <= N - 1: if S[left] == S[right]: val += 2 left -= 1 right += 1 ans = max(ans, val) print(ans)