S = eval(input())

bs = [0]

for c in S:

    bs.append(bs[-1] + int(c=='B'))



ans = 0

for b,c in zip(bs[1:],S):

    if c == 'W':

        ans += b

print(ans)
S = eval(input())



ans = b = 0

for c in S:

    if c == 'B':

        b += 1

    else:

        ans += b

print(ans)
S = eval(input())
bs = [0]
for c in S:
    bs.append(bs[-1] + int(c == "B"))
ans = 0
for b, c in zip(bs[1:], S):
    if c == "W":
        ans += b
print(ans)

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

-bs = [0] +ans = b = 0 -    bs.append(bs[-1] + int(c == "B")) -ans = 0 -for b, c in zip(bs[1:], S): -    if c == "W": +    if c == "B": +        b += 1 +    else: