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 s1;
  int numn = 0, ans = 0, cnt = 1;
  cin >> s1;
  int duan = 0;
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] == 'b') {
      cnt *= max(1, ans);
      if (ans) duan++;
      ans = 0;
    } else if (s1[i] == 'a') {
      ans++;
      numn++;
    }
  }
  if (ans) duan++;
  cnt *= max(1, ans);
  if (duan <= 1)
    cout << numn;
  else
    cout << cnt + numn;
  return 0;
}
