s = input() n = len(s) for i in range(n//2): if s[i] != s[-i-1]: print("{}".format(n)) exit() for i in range(n//2-1): if (s[i] != s[-i-3]) | (s[i] != s[-i-2]): print("{}".format(n-2)) exit() if (s[i+2] != s[-i-1]) | (s[i+1] != s[-i-1]): print("{}".format(n-2)) exit() ans = -(n % 2) print("{}".format(ans))