aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

import java.util.ArrayList;
import java.util.Scanner;

public class fairstring {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.next();
        
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i < str.length(); i++) {
            int val = 0;
            while (i < str.length() && str.charAt(i) != 'b') {
                if (str.charAt(i) == 'a')
                    val++;
                i++;
            }
            if (val != 0)
                arr.add(val);
        }
        
        int val = 0; 
        int n = arr.size();
        for (int i = 0; i < n; i++) {
            val += arr.get(i);
        }
        
        if (arr.size() == 1)
            System.out.println(val);
        else {
            val = (int) java.lang.Math.pow(2.0, (double) val);
            val -= 1;
        
            for (int i = 0; i < n; i++) {
                if (arr.get(i) > 1) {
                    val -= (arr.get(i) * (n-i));
                }
            }
            
            System.out.println(val);
        }
    }
}