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