aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

s=input()
s+='c'
ss=[]
temp=[]
last=''
for i in s:
	if i=='a':
		last+=i
	else:
		if last!='':
			temp.append(len(last))
			last=''
		if i!='b':
			ss.append(temp)
			temp=[]
ans=0
for i in ss:
	if len(i)==1:
		ans+=i[0]
	else:
		ans+=sum(i)
		for j in range(len(i)):
			for k in range(j+1,len(i)):
				ans+=i[j]*i[k]

print(ans)