#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.size();
  int a = 0;
  for (auto c : s)
    if (c == 'a') a++;
  int n_a = l - a;
  if (a > n_a)
    cout << l;
  else if (a == n_a)
    cout << l - 1;
  else
    cout << 2 * a - 1;
  return 0;
}
