S = eval(input())

N = S.count('W')



B = [b for b in range(1, N + 1) if S[b-1] == 'B']

W = [w for w in range(N+1, len(S)+1) if S[w-1] == 'W']

# assert len(B) == len(W)



ans = 0

for b, w in zip(B, W):

    ans += w - b



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

N = S.count('W')



B = [b for b in range(1, N + 1) if S[b-1] == 'B']

W = [w for w in range(N+1, len(S)+1) if S[w-1] == 'W']

# assert len(B) == len(W)



print((sum(W) - sum(B)))
S = eval(input())
N = S.count("W")
B = [b for b in range(1, N + 1) if S[b - 1] == "B"]
W = [w for w in range(N + 1, len(S) + 1) if S[w - 1] == "W"]
# assert len(B) == len(W)
ans = 0
for b, w in zip(B, W):
    ans += w - b
print(ans)

S = eval(input())
N = S.count("W")
B = [b for b in range(1, N + 1) if S[b - 1] == "B"]
W = [w for w in range(N + 1, len(S) + 1) if S[w - 1] == "W"]
# assert len(B) == len(W)
print((sum(W) - sum(B)))

-ans = 0 -for b, w in zip(B, W): -    ans += w - b -print(ans) +print((sum(W) - sum(B)))