S = eval(input())



ans = 0

num = 0

for i in range(len(S)):

    if S[i] == 'W':

        ans += (i - num)

        num += 1

print(ans)

S = eval(input())



ans = 0

b_count = 0

for i in range(len(S)):

    if S[i] == 'B':

        b_count += 1

    else:

        ans += b_count



print(ans)

S = eval(input())
ans = 0
num = 0
for i in range(len(S)):
    if S[i] == "W":
        ans += i - num
        num += 1
print(ans)

S = eval(input())
ans = 0
b_count = 0
for i in range(len(S)):
    if S[i] == "B":
        b_count += 1
    else:
        ans += b_count
print(ans)

-num = 0 +b_count = 0 -    if S[i] == "W": -        ans += i - num -        num += 1 +    if S[i] == "B": +        b_count += 1 +    else: +        ans += b_count