#include <bits/stdc++.h>
int main() {
  std::string s;
  std::cin >> s;
  int a = 0, len = 0;
  for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
    len += 1;
    if (*it == 'a') {
      a += 1;
    }
  }
  if (a <= len / 2) {
    std::cout << 2 * a - 1;
  } else {
    std::cout << len;
  }
  return 0;
}
