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

namespace Takmicenje2._3
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] rec = Console.ReadLine().ToCharArray();
            int rez;

            if (rec.Length == 1 || Palindrom(rec)) {
                Console.WriteLine("1");
            }
            else if (rec[0] == rec.Last()) {
                for (int i = 0, j = rec.Length - 1; i != j; i++, j--) {
                    if (rec[i] != rec[j]) {
                        rez = j - i;
                        Console.WriteLine(rez);
                        break;
                    }
                }
            }
            else {
                int len = rec.Length;
                int pom = 0;

                for (int i = 0, j = rec.Length - 1; i < rec.Length && j > 0; i++, j--) {
                    char temp = rec[j];
                    rec[j] = rec[j-1];
                    rec[j-1] = temp;

                    if (Palindrom(rec)) {
                        rez = len - (j-1);
                        Console.WriteLine(rez);
                        break;
                    }
                }
            }

            Console.ReadKey();
        }

        static bool Palindrom(char[] rec) {
            return rec.SequenceEqual(rec.Reverse());
        }
    }
}