s = eval(input())

ans = 0

count = 0

for i in range(len(s)):

    if s[i] == "W":

        ans += i - count

        count += 1

print(ans)
s = eval(input())

count = 0

ans = 0

for i in s:

    if i == "B":

        count += 1

    else:

        ans += count

print(ans)
s = eval(input())
ans = 0
count = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i - count
        count += 1
print(ans)

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

+count = 0 -count = 0 -for i in range(len(s)): -    if s[i] == "W": -        ans += i - count +for i in s: +    if i == "B": +    else: +        ans += count