#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  string s;
  int count = 0, l, mid;
  cin >> s;
  l = s.length();
  for (int i = 0; i < l; i++) {
    if (s[i] == 'a') {
      count++;
    }
  }
  mid = l / 2;
  while (mid >= count) {
    l--;
    mid = l / 2;
  }
  cout << l;
  return 0;
}
