#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int good = 0;
  int bad = 0;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s.at(i) == 'a')
      good++;
    else
      bad++;
  }
  if (good > bad)
    cout << s.length();
  else
    cout << s.length() - (bad - good) - 1;
  return 0;
}
