S = eval(input())

length = len(S)

countB = 0

for c in S:

    if c == 'B':

        countB += 1

soko = 1

ans = 0

for i in range(length):

    if S[-i-1] == 'B':

        ans += i + 1  - soko

        soko += 1

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

length = len(S)

soko = 1

ans = 0

for i in range(length):

    if S[-i-1] == 'B':

        ans += i + 1  - soko

        soko += 1

print(ans)
S = eval(input())
length = len(S)
countB = 0
for c in S:
    if c == "B":
        countB += 1
soko = 1
ans = 0
for i in range(length):
    if S[-i - 1] == "B":
        ans += i + 1 - soko
        soko += 1
print(ans)

S = eval(input())
length = len(S)
soko = 1
ans = 0
for i in range(length):
    if S[-i - 1] == "B":
        ans += i + 1 - soko
        soko += 1
print(ans)

-countB = 0 -for c in S: -    if c == "B": -        countB += 1