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