#include <bits/stdc++.h>
using namespace std;
long long int nCrModp(long int n, long int r, long int p) {
  long long int C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long int i = 1; i <= n; i++) {
    for (long int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
long long int pmod(long long int _a, long long int _b, long long int _m) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r;
}
long int fast() {
  long int val = 0;
  char c = getchar();
  while (c < 33) c = getchar();
  while (c > 33) val = (val << 1) + (val << 3) + (c - '0'), c = getchar();
  return val;
}
long long int fastt() {
  long long int val = 0;
  char c = getchar();
  while (c < 33) c = getchar();
  while (c > 33) val = (val << 1) + (val << 3) + (c - '0'), c = getchar();
  return val;
}
bool pal(char *a, int l) {
  for (int i = 0; i < l / 2; i++) {
    if (a[i] != a[l - i - 1]) return 0;
  }
  return 1;
}
bool isprime(long int n) {
  for (long int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return 0;
  }
  return 1;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int gcdExtended(long long int a, long long int b, long long int *x,
                          long long int *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int modInverse(long long int a, long long int m) {
  long long int x, y;
  long long int g = gcdExtended(a, m, &x, &y);
  long long int res = (x % m + m) % m;
  return res;
}
int main() {
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'a') c++;
  }
  cout << min((int)s.length(), c * 2 - 1) << endl;
}
