L = list(eval(input()))

memo = L.count("W")

ans = 0

for i in range(len(L)) :

    if L[i] == "W" :

        memo -= 1

    else :

        ans += memo

print(ans)

S = eval(input())

b = 0

ans = 0

for s in S :

    if s == "B" :

        b += 1

    else :

        ans += b

print(ans)
L = list(eval(input()))
memo = L.count("W")
ans = 0
for i in range(len(L)):
    if L[i] == "W":
        memo -= 1
    else:
        ans += memo
print(ans)

S = eval(input())
b = 0
ans = 0
for s in S:
    if s == "B":
        b += 1
    else:
        ans += b
print(ans)

-L = list(eval(input())) -memo = L.count("W") +S = eval(input()) +b = 0 -for i in range(len(L)): -    if L[i] == "W": -        memo -= 1 +for s in S: +    if s == "B": +        b += 1 -        ans += memo +        ans += b