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() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str, temp;
  cin >> temp;
  for (int i = 0; i < temp.length(); i++)
    if (temp[i] == 'a' || temp[i] == 'b') str.push_back(temp[i]);
  int ans = 0, count = 0, flag = 0;
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == 'a') {
      ans++;
      ans += (pow(2, count) - 1);
      flag = 1;
    } else {
      if (flag) {
        count++;
        flag = 0;
      }
    }
  }
  cout << ans << endl;
}
