#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ac = 0, m;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      ac++;
    }
  }
  while (true) {
    m = n / 2 + 1;
    if (ac >= m) {
      break;
    }
    n--;
  }
  cout << n << endl;
}
