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