#include <bits/stdc++.h>
using namespace std;
void find(string str) {
  int n1 = 0;
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == 'a') n1++;
  }
  if (n1 > (str.length()) / 2) {
    cout << str.length() << endl;
    return;
  }
  cout << (2 * n1) - 1 << endl;
}
int main() {
  string str;
  cin >> str;
  find(str);
  return 0;
}
