using System;

namespace Z3_Palindrom_Safl
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, j=0, k=0, l=0, p, n, x=1, y;
            string s = Console.ReadLine();
            n = s.Length;
            for (i = 0; i < n; i++)
            {
                if ((s[i] == 'b') && (k == 0))
                {
                    j = i;
                    k = 1;
                }
                else if((s[i] == 'b') && (k == 1))
                {
                    l = i;
                    break;
                }
            }
            p = n - j - 1;
            y = p - l;
            x = x + Math.Abs(y);
            Console.WriteLine(x);
        }
    }
}