#include <bits/stdc++.h>
int main() {
  char a[51];
  scanf("%s", a);
  int len = strlen(a);
  int banyak_a = 0;
  int bukan_a = 0;
  int setengah = len / 2;
  for (int i = 0; i < len; i++) {
    if (a[i] == 'a') {
      banyak_a++;
    } else {
      bukan_a++;
    }
  }
  if (banyak_a == 1) {
    printf("1\n");
  } else if (banyak_a <= bukan_a) {
    printf("%d\n", banyak_a + (banyak_a - 1));
  } else if (banyak_a > bukan_a) {
    printf("%d\n", len);
  }
  return 0;
}
