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