S = eval(input())

N = S.count('W')

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

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

print((W-B))
S = eval(input())

N = S.count('W')

B = sum([b for b in range(N) if S[b] == 'B'])

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

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

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

-B = sum([b for b in range(1, N + 1) if S[b - 1] == "B"]) -W = sum([w for w in range(N + 1, len(S) + 1) if S[w - 1] == "W"]) +B = sum([b for b in range(N) if S[b] == "B"]) +W = sum([w for w in range(N, len(S)) if S[w] == "W"])