S = list(eval(input()))

count_B = 0

ans = 0

for i in range(len(S)):

    if S[i] == "B":

        count_B += 1

    elif S[i] == "W":

        ans += count_B

print(ans)
S = eval(input())

ans = 0

cnt = 0

for s in S:

    if s == "B":

        cnt += 1

    else:

        ans += cnt

print(ans)
S = list(eval(input()))
count_B = 0
ans = 0
for i in range(len(S)):
    if S[i] == "B":
        count_B += 1
    elif S[i] == "W":
        ans += count_B
print(ans)

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

-S = list(eval(input())) -count_B = 0 +S = eval(input()) -for i in range(len(S)): -    if S[i] == "B": -        count_B += 1 -    elif S[i] == "W": -        ans += count_B +cnt = 0 +for s in S: +    if s == "B": +        cnt += 1 +    else: +        ans += cnt