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