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(); while (IsPalindrome(s)) { if (s.Length == 1) { WriteLine(-1); return; } if (s.Length == 2) { WriteLine(0); return; } s = string.Concat(s.Take(s.Length - 2)); } WriteLine(s.Length); } 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; } }