S = input() countA = 0 ans = 0 for i in range(len(S)): if S[i] == 'A': ans += i - countA countA+=1 print(countA)