#include <bits/stdc++.h>
using namespace std;
int main() {
  int temp, counter = 0;
  char input[50];
  scanf("%s", input);
  for (int i = 0; i < strlen(input); i++) {
    if (input[i] == 'a') counter++;
  }
  if (counter <= strlen(input) / 2) {
    printf("%d", counter + counter - 1);
  } else
    printf("%d", strlen(input));
  return 0;
}
