#include <bits/stdc++.h>
using namespace std;
void find(string str, int n) {
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'a') c++;
  }
  int c2 = n - c;
  if (c > c2) {
    cout << n << endl;
    return;
  }
  while (1) {
    if (c > c2) break;
    c2--;
  }
  cout << c + c2 << endl;
}
int main() {
  string str;
  cin >> str;
  int n = str.length();
  find(str, n);
  return 0;
}
