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