S = input() L = len(S) res = 0 for i in range(L): tmp = 1 for j in range(min(i, L - 1 - i)): if S[i - j - 1] == S[i + j + 1]: tmp += 2 res = max(res, tmp) for i in range(L - 1): if S[i] != S[i + 1]: continue tmp = 2 for j in range(min(i, L - 2 - i)): if S[i - j - 1] == S[i + j + 2]: tmp += 2 res = max(res, tmp) print(res)