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;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9 + 7;
const long double pi = acos(-1);
string s;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  int acc = 0, acc_tmp = 0;
  bool taok = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'b') {
      acc += acc_tmp;
      acc_tmp = 0;
    } else if (s[i] == 'a') {
      acc_tmp += 1 + acc;
    }
  }
  cout << acc + acc_tmp << endl;
  return 0;
}
