#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  for (int k = 0; k < n; k++) {
    if (s[k] == 'a') cnt++;
  }
  while (n / 2 >= cnt) {
    n = n - 1;
  }
  cout << n;
}
