#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, d = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'a')
      a++;
    else
      d++;
  if (a > d)
    cout << s.size();
  else
    cout << s.size() - (d - a + 1);
}
