#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast();
  string s;
  cin >> s;
  int len = s.length();
  int x = 0, a = 0;
  for (int i = 0; s[i] != '\0'; i++) {
    if (s[i] == 'a') {
      a++;
    } else
      x++;
  }
  while (x >= a) {
    len--;
    a++;
  }
  cout << len;
  return 0;
}
