S = input() count = 0 num_A = 0 for c in S: if c == 'A': num_A += 1 else: count += num_A print(count)