S = input() ans = 0 if len(set(S)) != 1: for i,s in enumerate(S): if s == "A": j = 0 for j in range(i - 1,0,-1): if S[j - 1] == "A": break ans+=i - j print(ans)