#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n1 = 0, n2 = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'b')
        {
            if (n1 != 0) n2 += i;
            else n1 += i;
        }
    }
    n1++;
    n2++;
    if (n1 == s.length() - n2 + 1) cout << "1";
    else if (n1 < (s.length() / 2) && n2 < (s.length() / 2) + 1) cout << s.length() / 2 + 2 - n1;
    else if (n1 < (s.length() / 2) && n2 == (s.length() / 2) + 1) cout << n2 - n1;
    else if (n1 < (s.length() / 2) && n2 > (s.length() / 2) + 1) cout << (n2 - s.length() / 2 + 1) - (s.length() / 2 - n1) + 1;
    else if (n1 == (s.length() / 2) && n2 > (s.length() / 2) + 1) cout << n2 - s.length() / 2;
    else if (n1 > (s.length() / 2) && n2 > n1) cout << n2 - s.length() / 2 + 1;
    return 0;
}