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