x = list(input()) y = list(reversed(x)) if x != y: print(len(x)) else: if x.count(x[0]) == len(x): print(- (len(x) % 2)) else: print(len(x) - 2)