using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static int Zadatak()
        {
            string s = Console.ReadLine();
            int l, d = s.Length / 2;
            char p;
            char[] a = s.ToCharArray();
            for (int i = 0; i < d; i++)
            {
                if (a[i] != a[s.Length - i - 1])
                {
                    bool t = true;
                    for (int j = s.Length - i - 2; j > i; j--)
                    {
                        if (a[i] == a[j])
                        {
                            p = a[j];
                            a[j] = a[s.Length - i - 1];
                            a[s.Length - i - 1] = p;
                            t = false;
                            break;
                        }
                    }
                    if (t)
                    {
                        p = a[s.Length / 2];
                        a[s.Length / 2] = a[i];
                        a[i] = p;
                    }
                }
            }
            l = 0;
            d = s.Length - 1;
            while (l < d && (a[l] == s[l] || a[d] == s[d]))
            {
                if (a[l] == s[l])
                {
                    l++;
                }
                if (a[d] == s[d])
                {
                    d--;
                }
            }
            if(d - l + 1 == 0)
            {
                return 2;
            }    
            return d - l + 1;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Zadatak());
        }
    }
}