aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

old_palavra = input()
a_palavra = []
for letra in old_palavra:
    if letra == "a":
        a_palavra.append(letra)
    if letra == "b" and len(a_palavra) > 0 and a_palavra[-1] == "a":
        a_palavra.append(letra)
matrix_palavra = [[]]
arrayinterno = 0
for i in a_palavra:
    if i == "a":
        matrix_palavra[arrayinterno].append(i)
    else:
        matrix_palavra.append([])
        arrayinterno += 1
tamanhos_de_arrays = []
for i in matrix_palavra:
    tamanhos_de_arrays.append(len(i) +1)

resultado =  tamanhos_de_arrays[0]
for i in range(1, len(tamanhos_de_arrays)):
    resultado *= tamanhos_de_arrays[i]

print(resultado -1)

 	 				  					 	  	 	  				 		