#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, t;
  int z = 0;
  int y = 0;
  string s;
  cin >> s;
  n = s.length();
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == 'a') z += 1;
  }
  x = n - z;
  if (z > x)
    cout << n;
  else {
    t = n;
    while (z <= x) {
      y += 1;
      t -= 1;
      x = t - z;
    }
    cout << n - y;
  }
}
