aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

import sys
readline = sys.stdin.readline
mod = 10**9+7
 
L = []
for s in readline().strip():
    if s == 'a':
        L.append(1)
    elif s == 'b' and L and L[-1] != 0:
        L.append(0)


N = len(L)
dp = [0]*(N+1)
cnt = 0
for i in range(1, N+1):
    s = L[i-1]
    if s:
        dp[i] = dp[i-1] + dp[cnt] + 1
    else:
        dp[i] = dp[i-1]
        cnt = i
        
print(0 if not dp else dp[-1])        

			     				 	 		 			  	  	 		