#include <bits/stdc++.h>
const double pi = 3.1415926535897;
using namespace std;
int main() {
  string s;
  cin >> s;
  int counter = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'a') counter++;
  }
  if (s.length() / 2 < counter)
    cout << s.length();
  else
    cout << (counter - 1) * 2 + 1;
}
