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