using System;

namespace Palindrom_Safl_petlja
{
    class Program
    {
        static bool Palindrom(string s)
        {
            for(int i = 0; i < s.Length / 2; i++)
            {
                if (s[i] != s[s.Length - 1 - i])
                    return false;
            }
            return true;
        }
        static void Resenje(string s)
        {
            int br1 = 0, br2 = 0;
            if(Palindrom(s))
            {
                Console.WriteLine(1);
                return;
            }
            else
            {
                for(int i = 0; i < s.Length; i++)
                {
                    if (s[i] == 'a')
                        br1++;
                    else br2++;
                }
                if (Math.Abs(br1 - br2) == 1 || (Math.Abs(br1 - br2) == 0 && br1 % 2 == 0))
                    Console.WriteLine(2);
                else
                    Console.WriteLine(4);
            }

        }
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Resenje(s);
        }
    }
}