#include <bits/stdc++.h>
int main() {
  char s[50];
  gets(s);
  int i, j;
  int acount = 0;
  int n = strlen(s);
  for (i = 0; i < strlen(s); i++) {
    if (s[i] == 'a') {
      acount++;
    }
  }
  if (acount <= n) {
    while (acount <= n / 2) {
      n = n - 1;
    }
  }
  printf("%d\n", n);
  return 0;
}
