aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

s = input()
if "a" not in s:
    print(0)
elif "b" not in s[1:]:
    print(s.count("a"))
else:
    ca = 0
    l = []
    for i in range(len(s)):
        if s[i]=="a":
            ca += 1
        elif s[i]=="b" and ca != 0:
            l += [ca]
            ca = 0
    if s[len(s)-1]=="a":
        l += [ca]
    if len(l)==1:
        print(s.count("a"))
    else:
        print(s.count("a")+eval("*".join(str(x) for x in l)))