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

namespace p4
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, i = 0, m = 0, k = 0, br = 0, z = 0, f = 0, e = 0, j, z1 = 1;
            string s, d = "";
            char c = '0';
            s = Console.ReadLine();
            a = s.Length;
            while(i <a/2)
            {
                if(s[i]!=s[a-1-i])
                {
                    e++;
                }
                for(j=0;j<a/2;j++)
                {
                    if (s[i] == s[i + 1])
                        z1=0;
                }
                i++;
            }
            if (e == 0 && z1==1)
            {
                br = a / 2;
                Console.WriteLine(br);
            }
            else
            {
                int[] b = new int[10];
                for (i = 0; i < a / 2; i++)
                {
                    b[0] = s.LastIndexOf('0') - s.IndexOf('0');
                    b[1] = s.LastIndexOf('1') - s.IndexOf('1');
                    b[2] = s.LastIndexOf('2') - s.IndexOf('2');
                    b[3] = s.LastIndexOf('3') - s.IndexOf('3');
                    b[4] = s.LastIndexOf('4') - s.IndexOf('4');
                    b[5] = s.LastIndexOf('5') - s.IndexOf('5');
                    b[6] = s.LastIndexOf('6') - s.IndexOf('6');
                    b[7] = s.LastIndexOf('7') - s.IndexOf('7');
                    b[8] = s.LastIndexOf('8') - s.IndexOf('8');
                    b[9] = s.LastIndexOf('9') - s.IndexOf('9');
                    for (i = 0; i < 10; i++)
                    {
                        if (b[i] > 1 && m == 0)
                        {
                            m = b[i];
                            k = i;
                            z++;
                        }
                        if (b[i] > 1 && m != 0 && b[i] <= m)
                        {
                            m = b[i];
                            k = i;
                            z++;
                        }
                        if (b[i] > 1)
                        {
                            z++;
                        }
                        if (b[i] == a - 1)
                            f++;
                    }
                    if (z > 0)
                    {
                        d = Convert.ToString(k);
                        c = Convert.ToChar(d);
                        for (i = s.IndexOf(c); i < s.LastIndexOf(c); i++)
                        {
                            if (s[i] != c)
                            {
                                s = s.Remove(i, 1);
                                s = s.Insert(i, d);
                                br++;
                            }
                        }
                    }
                    if (br <= a - 2 && f == 1)
                    {
                        br = 1;
                    }
                }
                Console.WriteLine(br);
            }
            Console.ReadLine();
        }
    }
}