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