#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, cnt = 0, a = 0;
  char s[100000];
  cin >> s;
  n = strlen(s);
  for (i = 0; i < n; i++) {
    if (s[i] == 'a')
      a++;
    else
      cnt++;
  }
  if (a > cnt)
    cout << n << endl;
  else {
    cout << a + (a - 1) << endl;
  }
}
