aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

string=input()
counter=0
if 'b' not in string:
    print(string.count('a'))
else:
    counter+=string.count('a')
    countera=0
    counterb=0
    counterst=string.count('a')
    for i in range(len(string)):
        if string[i]=='a':
            if counterb==0:
                pass
            else:
                counter+=(counterst-countera)*countera
                counterst-=countera
                counterb=0
            countera+=1
        elif string[i]=='b':
            if i==0:
                continue
            counterb+=1
    print(counter)