#include <bits/stdc++.h>
using namespace std;
string s;
long long ans;
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> s;
  for (long long i = 0; i < s.size(); i++)
    if (s[i] == 'a') ans++;
  return cout << min(ans * 2 - 1, (long long)s.size()), 0;
}
