aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

//package com.company;

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

public class CF_1084_C {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        ArrayList<Integer> arr=new ArrayList<>();
        boolean flag=true;
        int i=0;
        long ans=0;
        int sum=0;
        int last=1;
        arr.add(1);
        while(i<s.length()) {
            if (s.charAt(i) == 'a') {
                int j = i;
                while (i < s.length() && s.charAt(i) == s.charAt(j))
                    i++;
//                int k=
                if(flag) {
                    last=2*(i-j)*last;
                    sum+=i-j;
                } else {
                    ans+=last-sum;
                    sum=i-j;
                    last=2*(i-j);
                }
                flag = false;
            } else if (s.charAt(i) == 'b') {
                flag = true;
                i++;
            } else{
                i++;
            }
        }
        ans+=last-sum;
        System.out.println(ans);
    }
}
