aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long c = 1;
  while (b) {
    if (b & 1) c *= a;
    a *= a;
    b /= 2;
  }
  return c;
}
void solve() {
  string s;
  cin >> s;
  long long n = s.size();
  long long i, j, k;
  long long counta = 0;
  for (i = 0; i < n; i++)
    if (s[i] == 'a') counta++;
  if (counta == 0)
    cout << "0\n";
  else {
    vector<long long> v;
    counta = 0;
    for (i = 0; i < n; i++) {
      if (s[i] == 'a')
        counta++;
      else if (s[i] == 'b') {
        v.push_back(counta);
        counta = 0;
      } else
        ;
    }
    v.push_back(counta);
    long long ans = 1;
    for (i = 0; i < v.size(); i++) {
      ans *= v[i] + 1;
    }
    cout << ans - 1 << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) solve();
  return 0;
}
