using System;

namespace ZadatakPalindrom
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] t = Console.ReadLine().ToCharArray();
            int ll = 0, ld = 0, dl = 0, dd =0, l = 0, d = t.Length - 1;
            for (int i = 0; i <t.Length / 2 + t.Length%2; i++)
            {
                int j = 0;
                int u = 1;
                if (t[i] != t[t.Length - 1 - i])
                {
                    if (ll == -1)
                    {
                        ll = i;
                        dd = t.Length - 1 - i;
                    }
                    while (u!=0 &&(t[l + j] != t[d] || t[l] != t[t.Length - 1 - j]) )
                    {
                        if (t[l + j + 1] == t[d])
                        {
                            ld = l + j + 1;
                            char c = t[l];
                            t[l] = t[l + 1 + j];
                            t[l + 1 + j] = c;
                            u = 0;
                        }
                        else if (t[l] == t[d - j - 1])
                        {
                            dl = t.Length - 2 - j;
                            char c = t[d];
                            t[d] = t[d - j - 1];
                            t[d - j - 1] = c;
                            u = 0;
                        }
                        j++;
                    }
                }
                l++;
                d--;
            }
            if (ld - ll <= dd - dl) Console.WriteLine(dd - dl+1);
            else Console.WriteLine(ld - ll+1);
        }
    }
}