#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int aa = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'a') aa++;
  if (2 * aa > n)
    cout << n;
  else
    cout << 2 * aa - 1;
  return 0;
}
