s = eval(input())

b = s.count("B")

n = len(s)

cou = 0

ans = 0

for i in reversed(list(range(n))):

    if s[i] == "B":

        ans += n - 1 - cou - i

        cou += 1

print(ans)
s = eval(input())

n = len(s)



ans = 0

cou = 0

for i in range(n):

    if s[i] == "W":

        ans += i - cou

        cou += 1

print(ans)
s = eval(input())
b = s.count("B")
n = len(s)
cou = 0
ans = 0
for i in reversed(list(range(n))):
    if s[i] == "B":
        ans += n - 1 - cou - i
        cou += 1
print(ans)

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

-b = s.count("B") +ans = 0 -ans = 0 -for i in reversed(list(range(n))): -    if s[i] == "B": -        ans += n - 1 - cou - i +for i in range(n): +    if s[i] == "W": +        ans += i - cou