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