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 unsigned long long int mod = 1e9 + 7;
const long long int inf = (long long int)1e18 + 2;
const long long int N = (long long int)2e5 + 2;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
void solve() {
  string str;
  cin >> str;
  long long int n = str.size();
  long long int dp[n], ok = 0, cnt = 0;
  memset(dp, 0, sizeof(dp));
  for (long long int i = 0; i < n; i++) {
    if (str[i] == 'b') {
      if (i > 0) dp[i] = dp[i - 1];
      ok = dp[i];
      continue;
    } else if (str[i] != 'a') {
      if (i > 0) dp[i] = dp[i - 1];
    } else {
      cnt++;
      if (i == 0)
        dp[i]++;
      else
        dp[i] = dp[i - 1] + 1 + ok;
    }
  }
  cout << dp[n - 1] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
