import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = read().rstrip().decode() B = 0 answer = 0 for x in S: if x == 'B': B += 1 else: answer += B print(answer)