S=input() A=0 ANS=0 for s in S: if s=="B": ANS+=A else: A+=1