aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

def read(type = 1):
    if type:
        file = open("input.dat", "r")
        s = file.readline()
        file.close()
    else:
        s = input().strip()
    return s


def solve():
    sol = 1
    c = []
    for i in range(len(s)):
        if s[i] == "a":
            if len(c):
                c.append(c[-1]+1)
            else:
                c.append(1)
        if s[i] == "b":
            if len(c):
                if c[-1] != 0:
                    sol *= (c[-1] + 1)
                    c.append(0)
    if len(c):
        if c[-1]:
            sol *= (c[-1] + 1)
    return sol-1

s = read(0)
sol = solve()
print(sol)