#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  string s;
  cin >> s;
  n = s.length();
  long long int i = 0, c = 0;
  while (s[i] != '\0') {
    if (s[i] == 'a') c++;
    i++;
  }
  if (c > n / 2)
    cout << n;
  else {
    cout << 2 * c - 1;
  }
  return 0;
}
