def solve(): s = input() n = len(s) if s != s[::-1]: return n ss = set(s) if len(ss) == 1: return 0 return n - 2 print(solve())