#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5;
long long n;
char str[55];
void solve() {
  n = strlen(str + 1);
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (str[i] == 'a') {
      cnt++;
    }
  }
  printf("%lld\n", min(cnt * 2 - 1, n));
}
int main() {
  while (~scanf("%s", str + 1)) {
    solve();
  }
}
