#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int counta = 0;
  int x = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') {
      counta++;
    }
    x++;
  }
  int ans = ((2 * counta) - 1);
  if (ans < 0) {
    ans *= -1;
  }
  if (counta > x / 2) {
    cout << x << "\n";
  } else {
    cout << ans << "\n";
  }
  return 0;
}
