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;
int main() {
  string s, a;
  cin >> s;
  long long n = s.size();
  long long sol = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'a' || s[i] == 'b') {
      a.push_back(s[i]);
    }
  }
  vector<long long> dp;
  long long k = 0;
  for (long long i = 0; i < a.size(); i++) {
    if (a[i] == 'a') {
      k++;
    } else {
      if (k != 0) dp.push_back(k);
      k = 0;
    }
  }
  if (k != 0) dp.push_back(k);
  if (!dp.empty()) sol = dp[0];
  for (long long i = 1; i < dp.size(); i++) {
    sol += dp[i];
    sol += dp[i] * dp[i - 1];
  }
  cout << sol;
  return 0;
}
