#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
int main() {
  string w;
  cin >> w;
  vector<char> v;
  for (char c : w) {
    v.push_back(c);
  }
  lint a = count(v.begin(), v.end(), 'a');
  cout << min(2 * a - 1, static_cast<lint>(w.size())) << endl;
  return 0;
}
