#include <bits/stdc++.h>
using namespace std;
const int mm = 1e5 + 10;
long long a1, a2, a3, a4, a5, a6, a7, a8, n, m, ez1;
string s, s1;
int inp[mm];
bool flag[mm];
int ans;
void input() { cin >> s; }
void solve() {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') a1++;
  }
  int u = s.size();
  if (a1 > u / 2)
    cout << u << endl;
  else
    cout << a1 + a1 - 1 << endl;
}
int main() {
  input();
  solve();
  return 0;
}
