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;
string s;
int a[100005];
void input() {
  cin >> s;
  return;
}
void solve() {
  long long j = 1;
  long long sum = 0;
  bool check = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'a') {
      a[j]++;
      check = 1;
    }
    if (s[i] == 'b' && check == 1) {
      sum += a[j] + sum * a[j];
      j++;
      check = 0;
    }
  }
  sum += a[j] + sum * a[j];
  cout << sum;
  return;
}
void output() { return; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  {
    input();
    solve();
    output();
  }
  return 0;
}
