s=input() l=[i for i,j in enumerate(s) if j=="A"] print(sum(map(lambda x,y:x-y,l,range(len(l)))))