S = list(input()) N = len(S) s = set(S) if len(s) == 1: if len(S) % 2 == 1: print (-1) else: print (0) else: flag = True for i in range(N): if S[i] != S[len(S)-1-i]: flag = False if not flag: print (len(S)) else: print (len(S)-2)