aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

from sys import stdin, stdout
string = stdin.readline()
m = 10**9 + 7

lst = []
for i in string:
    if i == 'a':
        lst.append(1)
    elif i == 'b':
        if lst == [] or lst[-1] == 0:
            continue
        else:
            lst.append(0)

memo = [-1 for i in range(len(lst))]


# lst[index] will always be 0
def rsolve(index):
    if memo[index] != -1:
        return memo[index]
    ans = 1
    b = -1
    for i in range(index+1, len(lst)):
        if lst[i] == 0:
            b = i
            break
    if b == -1:
        memo[index] = ans
    else:
        for i in range(b, len(lst)):
            if lst[i] == 1:
                ans += rsolve(i)
        memo[index] = ans
    return memo[index]

ans = 0
for i in range(len(lst)):
    if lst[i] == 1:
        ans += rsolve(i)
stdout.write(str(ans))
