#include <iostream>

using namespace std;

int main()
{
    int z = 0, br1 = -1, br2 = -1;
    string niska;
    cin >> niska;
    int d = niska.length();
    for (br1 = 0; br1 < d; br1++)
    {
        if (niska[br1] == 'b')
        {
            break;
        }
    }
    for (br2 = d - 1; br2 >= 0; br2--)
    {
        if (niska[br2] == 'b')
        {
            break;
        }
    }
    br2 = d - br2 - 1;
    cout << abs(br1 - br2) + 1;
    return 0;
}