s = input().strip() t = 0 count = 0 for i in range(len(s)): if s[i] == 'B': t += 1 else: count += t print(count)