using System;
using System.IO;
using System.Text;

namespace Palindrom_šafl
{
    internal class Program
    {
        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        static string Substring(string str, int i, int j)
        {
            string deo;
            if (i <= j) deo = str.Substring(i, j - i + 1);
            else {
                deo = str.Substring(j, i - j + 1);
                Reverse(deo);
            }
            
            return deo;
        }

        static bool Palindrom(string s, ref int r, int i, int j)
        {
            int d;
            int rr = (Math.Abs(j - i) + 1) < r || r == 0 ? Math.Abs(j - i) + 1 : r;
            string deo;
            char[] str = s.ToCharArray();
            deo = Substring(s, i, j);
            if (i <= (str.Length + 1) / 2) d = 1; else d = -1;
            for (int x = 0; x < Math.Abs(j - i) + 1; x++)
            {
                if (str[i] != str[str.Length - i - 1])
                {
                    if (deo.IndexOf(str[str.Length - i - 1]) >= 0)
                    {
                        int index = s.IndexOf(str[str.Length - i - 1]);
                        char temp = str[i];
                        str[i] = str[index];
                        str[deo.IndexOf(str[i]) + (i <= j ? i : j)] = temp;
                        s = new string(str);
                        i += d;
                        deo = Substring(s, i, j);
                    }else return false;

                }
            }
            r = rr;
            return true;
        }

        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader(Console.OpenStandardInput(), Encoding.UTF8, false, 1600008));
            string str = Console.ReadLine();
            int r = 0;
            int i1 = -1, i2 = -1, i3 = -1, i4 = -1;
            for(int i = 0; i < (str.Length + 1) / 2; i++)
            {
                if(str[i] != str[str.Length - i - 1])
                {
                    if (i1 == -1)
                    {
                        i1 = i;
                        i4 = str.Length - i - 1;
                    }
                    else
                    {
                        i2 = i;
                        i3 = str.Length - i - 1;
                    }
                }
            }
            if(i1 != -1)
            {
                Palindrom(str, ref r, i1, i4);
                if (i2 != -1)
                {
                    Palindrom(str, ref r, i1, i3);
                    Palindrom(str, ref r, i1, i2);
                    Palindrom(str, ref r, i4, i2);
                    Palindrom(str, ref r, i4, i3);
                }
            }
            Console.Write(r > 0 ? r : 1);
        }
    }
}