s=eval(input())

count=0

b=s.count("B")

w=s.count("W")

for x in range(len(s)):

    if s[x:x+1] == "B":

        count += w

        b-=1

    elif s[x:x+1] == "W":

        w-=1

    if w == 0:

        break



print(count)
s=eval(input())

count=0

b=s.count("B")

w=s.count("W")

for x in range(len(s)):

    if s[x:x+1] == "B":

        count += w

        b-=1

    elif s[x:x+1] == "W":

        w-=1

        

print(count)
s = eval(input())
count = 0
b = s.count("B")
w = s.count("W")
for x in range(len(s)):
    if s[x : x + 1] == "B":
        count += w
        b -= 1
    elif s[x : x + 1] == "W":
        w -= 1
    if w == 0:
        break
print(count)

s = eval(input())
count = 0
b = s.count("B")
w = s.count("W")
for x in range(len(s)):
    if s[x : x + 1] == "B":
        count += w
        b -= 1
    elif s[x : x + 1] == "W":
        w -= 1
print(count)

-    if w == 0: -        break