S = eval(input())

b = 0

ans = 0

for c in S:

    if c == 'B':

        b += 1

    else:

        ans += b

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

b = ans = 0

for c in S:

    if c=='B':

        b += 1

    else:

        ans += b

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

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

-b = 0 -ans = 0 +b = ans = 0