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