S = input()[::-1]

ans = 0

tmp = 0

bcnt = 0

N = len(S)

for i in range(N):

    if S[i]=="W":

        tmp += 1

    else:

        ans += tmp

        bcnt += 1

        tmp = i+1-bcnt



print(ans)

S = eval(input())



# 逆順にする

S = S[::-1]



# 黒石より右にある白石の数だけ操作可能

ans = 0

white = 0

for i in range(len(S)):

    if S[i]=="B":

        ans += white

    else:

        white += 1



print(ans)
S = input()[::-1]
ans = 0
tmp = 0
bcnt = 0
N = len(S)
for i in range(N):
    if S[i] == "W":
        tmp += 1
    else:
        ans += tmp
        bcnt += 1
        tmp = i + 1 - bcnt
print(ans)

S = eval(input())
# 逆順にする
S = S[::-1]
# 黒石より右にある白石の数だけ操作可能
ans = 0
white = 0
for i in range(len(S)):
    if S[i] == "B":
        ans += white
    else:
        white += 1
print(ans)

-S = input()[::-1] +S = eval(input()) +# 逆順にする +S = S[::-1] +# 黒石より右にある白石の数だけ操作可能 -tmp = 0 -bcnt = 0 -N = len(S) -for i in range(N): -    if S[i] == "W": -        tmp += 1 +white = 0 +for i in range(len(S)): +    if S[i] == "B": +        ans += white -        ans += tmp -        bcnt += 1 -        tmp = i + 1 - bcnt +        white += 1