#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == 'a') cnt++;
  }
  if (cnt > (int)s.length() / 2) {
    printf("%lu\n", s.length());
    return 0;
  }
  printf("%d\n", 2 * cnt - 1);
  return 0;
}
