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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] niz = new char[s.Length];
            niz = s.ToCharArray();
            int i = 0;
            int b1 = -1;
            int b2 = 0;
            while (i < s.Length)
            {
                if (niz[i] == 'b' && b1 == -1) b1 = i;
                if (niz[i] == 'b' && b1 != -1) b2 = i;
                i++;

            }
          
            Console.WriteLine(Math.Abs(s.Length -1 - b1 - b2)+1);
          //  Console.ReadLine();
        }
    }
}