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