using System; using System.Collections.Generic; using static System.Console; using System.Linq; class yuki1 { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static void Main() { var s = ReadLine(); WriteLine(Pa(s)); } static int Pa(string s) { if (!IsPalindrome(s)) { return s.Length; } else if (!IsOneChars(s) && s.Length != 3) { return s.Length - 2; } else { return 0 - (s.Length % 2); } } static bool IsOneChars(string s) { for (var i = 0; i < s.Length - 1; ++i) { if (s[i] != s[i + 1]) return false; } return true; } static bool IsPalindrome(string s) { for (var i = 0; i < s.Length / 2; ++i) { if (s[i] != s[s.Length - i - 1]) return false; } return true; } }