import sys

input = sys.stdin.readline

s = input().rstrip()



ans = 0

pos = 0

for i in range(len(s)):

    if s[i] == "W":

        ans += i-pos

        pos += 1



print(ans)

S = eval(input())



b = 0

ans = 0

for s in S:

    if s == "B":

        b += 1

    else:

        ans += b



print(ans)

import sys

input = sys.stdin.readline
s = input().rstrip()
ans = 0
pos = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i - pos
        pos += 1
print(ans)

S = eval(input())
b = 0
ans = 0
for s in S:
    if s == "B":
        b += 1
    else:
        ans += b
print(ans)

-import sys - -input = sys.stdin.readline -s = input().rstrip() +S = eval(input()) +b = 0 -pos = 0 -for i in range(len(s)): -    if s[i] == "W": -        ans += i - pos -        pos += 1 +for s in S: +    if s == "B": +        b += 1 +    else: +        ans += b