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