aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

s=raw_input()
x=""
l=len(s)
for i in range(l):
    if s[i]=='a':
        x+='a'
        break
for j in range(i+1,l):
    if s[j]=='a' or s[j]=='b':
        x+=s[j]
if len(x)==0:
    c=0
else:
    c=1
acount=0
for i in range(1,len(x)):
    if x[i]=='b':
        acount=c
    else:
        c+=acount+1
print c