using System;

namespace _3_zad_18_12
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();
            char[] a = b.ToCharArray();
            char pom;  
            int l = 0, d = 1, e = a.Length - 1;
            while (l < d && d < e)
            {
                
                if (a[l] == a[e])
                {
                    l++;
                    d++;  
                    e--;
                }
                else if (a[l] == a[d])
                {
                    pom = a[d];
                    a[d] = a[e];
                    a[e] = pom;

                }
                else if (a[d] == a[e])
                {
                    pom = a[l];
                    a[l] = a[d];
                    a[d] = pom;
                    d = l + 1;  
                }
                else d++;
            }
        
            int pombr=0;
               for(int i = 0; i < b.Length; i++)
            {
                if (a[i] != b[i])
                {
                    pombr = i;
                    break;
                }
            }
            int pombrr=1;
            
            for (int i = b.Length-1; i >=0; i--)
            {
                if (a[i] != b[i])
                {
                    pombrr = i;
                    break;
                }
            }
            Console.WriteLine(pombrr-pombr+1);
            
            
        }
    }
}