#include <bits/stdc++.h>
using namespace std;
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
void solve4() {
  string s;
  cin >> s;
  int c = 0;
  int n = int((s).size());
  for (char ch : s) {
    c += (ch == 'a');
  }
  long long ans;
  cerr << "n"
       << "=" << n << ","
       << "c"
       << "=" << c << endl;
  if (c > n / 2)
    ans = n;
  else
    ans = 2 * c - 1;
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve4();
}
