s = input() res = [i for i in range(len(s)) if s[i]=="A"] L = len(res) print(sum(res)-L*(L-1)//2)