using System;

namespace burh3
{
    class Program
    {
        static void countSwap(char[] str)
    {
        char[] s = str;
        int n = s.Length;
        int count = 0;
        for (int i = 0; i < n / 2; i++) {
            int left = i;
            int right = n - left - 1;
            while (left < right) {
                if (s[left] == s[right]) {
                    break;
                }
                else {
                    right--;
                }
            }
            if (left == right) {
                return;
            }
            else {
                for (int j = right; j < n - left - 1; j++) {
                    char t = s[j];
                    s[j] = s[j + 1];
                    s[j + 1] = t;
                    count++;
                }
            }
        }
    }

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] s1 = s.ToCharArray();
            char[] s1C = s.ToCharArray();

            char[] s2 = s.ToCharArray();
            char[] s2C = s.ToCharArray();
            Array.Reverse(s2);
            Array.Reverse(s2C);
            countSwap(s1C);
            countSwap(s2C);
            int max = 0;
            for(int i = 0;i<s1.Length;i++){
                if(s1[i]!=s1C[i]){ max = i; break;}
            }
            for(int i = s.Length-1;i>=0;i--){
                if(s1[i]!=s1C[i]){ max = i-max+1; break;}
            }
            int max2 = 0;
            for(int i = 0;i<s1.Length;i++){
                if(s2[i]!=s2C[i]){ max2 = i; break;}
            }
            for(int i = s.Length-1;i>=0;i--){
                if(s2[i]!=s2C[i]){ max2 = i-max+1; break;}
            }
            Console.WriteLine(Math.Min(max,max2));
        }       
    }
}