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())



ans = 0

b = 0

for ss in s:

    if ss == 'W':

        ans += b

    else:

        b += 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())
ans = 0
b = 0
for ss in s:
    if ss == "W":
        ans += b
    else:
        b += 1
print(ans)

-cnt = 0 -for c in s: -    if c == "B": -        cnt += 1 -    elif c == "W": -        ans += cnt +b = 0 +for ss in s: +    if ss == "W": +        ans += b +    else: +        b += 1