using System;

namespace ConsoleApplication1
{
    class Program
    {
        static bool Palindrom(string a)
        {
            int i = 0, j = a.Length - 1;
            while (i < j)
            {
                if (a[i] != a[j]) return false;
                i++;
                j--;
            }
            return true;
        }
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if (Palindrom(a)) Console.WriteLine(1);
            else
            {
                int n = a.Length;
                int i = 0;
                while (a[i] == a[n + i - 1])
                {
                    n -= 2;
                    i++;
                }
                if (a.Substring(i, n).IndexOf(a[i]) == a.Substring(i, n).LastIndexOf(a[i]))
                {
                    while (a.Substring(i, n).IndexOf(a[i + n - 1]) != a.Substring(i, n).LastIndexOf(a[i + n - 1]))
                    {
                        n--;
                    }
                }   
                else
                {
                    while (a.Substring(i, n).IndexOf(a[i]) != a.Substring(i, n).LastIndexOf(a[i]))
                    {
                        n--;
                        i++;
                    }
                }
                if (a.Length % 2 == 1 && (i == a.Length / 2 || i + n == a.Length / 2)) n--;
                Console.WriteLine(n);
            }
        }
    }
}