aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

s = input()
A = []
a = 0
b = 0
for i in range(len(s)):
    if s[i] == 'a':
        a += 1
        b = 0
    if s[i] == 'b':
        b += 1
        if a > 0:
            A.append(a);
            a = 0

if a > 0:
    A.append(a)
if len(A) > 0:
    dp = [0] * (len(A) + 1)
    dp[0] = A[0]
    for i in range(1, len(A)):
        dp[i] = dp[i - 1] + A[i] * (1 + dp[i - 1])

    print(dp[len(A) - 1])
else:
    print(0)
