#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int as = 0;
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'a') {
      as++;
    }
  }
  int ans = str.size();
  while ((ans) / 2 >= as) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
