s = eval(input())



right = len(s) - 1

i = right

ans = 0

while i >= 0:

    if s[i] == 'B':

        # print(right, i)

        ans += right - i

        right -= 1

    i -= 1

print(ans)

s = eval(input())



cnt = 0

ans = 0

for c in s:

    if c == 'B':

        cnt += 1

    elif c == 'W':

        ans += cnt

print(ans)

s = eval(input())
right = len(s) - 1
i = right
ans = 0
while i >= 0:
    if s[i] == "B":
        # print(right, i)
        ans += right - i
        right -= 1
    i -= 1
print(ans)

s = eval(input())
cnt = 0
ans = 0
for c in s:
    if c == "B":
        cnt += 1
    elif c == "W":
        ans += cnt
print(ans)

-right = len(s) - 1 -i = right +cnt = 0 -while i >= 0: -    if s[i] == "B": -        # print(right, i) -        ans += right - i -        right -= 1 -    i -= 1 +for c in s: +    if c == "B": +        cnt += 1 +    elif c == "W": +        ans += cnt