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 n = 0;
const long long mod = 1e9 + 7;
long long tt = 0;
void pre_solve() {}
void sol(long long tc) {
  string s;
  cin >> s;
  n = s.length();
  vector<long long> dp(n, 0);
  bool b = false;
  long long prev = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'a') {
      prev = i;
      dp[i] = 1;
      break;
    }
  }
  vector<long long> previous(n, -1);
  for (long long i = prev + 1; i < n; i++) {
    if (s[i] == 'a') {
      previous[i] = prev;
      if (b) {
        dp[i] = 2 * dp[prev] + 1;
      } else {
        dp[i] = dp[prev] + 1 + (previous[prev] != -1 ? dp[previous[prev]] : 0);
        previous[i] = previous[prev];
      }
      prev = i;
      b = false;
    } else {
      if (s[i] == 'b') b = true;
      dp[i] = dp[i - 1];
    }
  }
  cout << dp[n - 1];
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long tc = 1;
  while (tc--) {
    tt++;
    sol(tc);
  }
  return 0;
}
