import re P = re.compile('B') def f(s): t = len(s) - 1 if t == 0: return 0 l = [t - m.start() for m in P.finditer(s)] t = len(l) - 1 return sum(i-j for i,j in zip(l, range(t,-1,-1))) s = input() print(f(s))