#include <iostream>
#include <string>
typedef unsigned int ui;
using namespace std;
int main()
{
    string s;
    int br = 0;
    ui poc = 200000;
    cin >> s;
    for (ui i = 0; i < s.length() - i; i++)
    {
        if (s[i] == 'b' && s[s.length() - i - 1] == 'b')
        {
            cout << 1;
            break;
        }
        else {
            if (s[i] == 'b')poc = i;
            if (s[s.length() - i - 1] == 'b' && poc != 200000)
            {
                cout << s.length() - i - poc;
                break;
            }
        }
    }
    return 0;
}