using System;

namespace Palindrom_šafl
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] t = s.ToCharArray();
            int i = 0;
            int[] a = new int[2];
            int br = 0;
            while (i<t.Length)
            {
                if (t[i] == (char)98)
                {
                    a[br] = i;
                    br++;
                }
                i++;
            }
            Console.WriteLine(Math.Abs(((t.Length-1) - a[br-1])-a[br-2])+1);
        }
    }
}