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(); if (!IsPalindrome(s)) { WriteLine(s.Length); } else if (!IsOneChars(s)) { WriteLine(s.Length - 2); } else { WriteLine(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; } }