using System;

namespace ConsoleApp33
{
    class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            int l = 0, d = 0;
            while(t[l] != 'b')
            {
                l++;
            }
            while (t[t.Length-d-1] != 'b')
            {
                d++;
            }
            Console.WriteLine(l + d - 1);
        }
    }
}