#include <bits/stdc++.h>
using namespace std;
void solve() {
  string a;
  cin >> a;
  int x = 0;
  auto cnt = count(a.begin(), a.end(), 'a');
  int other = a.length() - (int)cnt;
  if (cnt > other) {
    cout << a.length() << "\n";
  } else {
    cout << a.length() - (other - cnt + 1);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1, i = 1;
  while (t--) {
    solve();
  }
  return 0;
}
