#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500500;
int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  int anum = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') {
      anum++;
    } else
      break;
  }
  if (anum > s.size() / 2) {
    cout << s.size() << endl;
  } else {
    cout << anum + (anum - 1) << endl;
  }
  return 0;
}
