#include <bits/stdc++.h>
using namespace std;
int n, cnt;
char x[55];
int main() {
  scanf("%s", x);
  n = strlen(x);
  for (int i = 0; i < n; i++) cnt += x[i] == 'a';
  printf("%d\n", min(n, cnt * 2 - 1));
}
