using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static int proveri(List<char> li)
        {
            int n = li.Count;
            int index = 0;
            List<char> nova = new List<char>(li);
            int br = 0;
            while (true)
            {
                char pocetak = nova[index];
                nova.RemoveAt(index);
                if (nova.Contains(pocetak))
                {
                    br++;
                }
                else if (br == nova.Count)
                {
                    br++;
                    break;
                }
                else
                    break;
            }
            return br;
        }
        
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int br = 1;
            List<char> li = new List<char>();
            foreach (char p in a)
                li.Add(p);
            int n = li.Count;

            
            //ako je paran ili neparan palindrom
            int pocetak = n;
            while (li.Count > 0 && li[0] == li[n - 1] && n > 1)
            {
                li.RemoveAt(n - 1);
                li.RemoveAt(0);
                n -= 2;
            }
            if (li.Count > 0)
            {
                int l = proveri(li);
                n -= l;
            }
            if (n > 1)
            {
                br = n;
            }
            Console.WriteLine(br);     
        }
    }
}