#include <bits/stdc++.h>
void count(char s[], int *a, int *b) {
  int i = 0;
  for (i = 0; i < strlen(s); i++) {
    if (s[i] == 'a') (*a)++;
    if (s[i] != 'a') (*b)++;
  }
}
int main() {
  char ch[50];
  int a = 0, b = 0;
  do {
    scanf("%s", ch);
  } while (strlen(ch) < 1 || strlen(ch) > 50);
  count(ch, &a, &b);
  while (b >= a) {
    b--;
  }
  printf("%d", a + b);
}
