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