s=list(eval(input()))

count=0

# print('lens',len(s))

indexes = [i for i, x in enumerate(s) if x == "B"]

ideal=sorted([len(s)-i-1 for i in range(len(indexes))])

# print(indexes)

# print(ideal)

for i in range(len(indexes)):

  count+=ideal[i]-indexes[i]



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

w=[i for i in range(len(s)) if s[i]=="W"]

ideal=[j for j in range(s.count('W'))]

print((sum([i-j for i,j in zip(w,ideal)])))
s = list(eval(input()))
count = 0
# print('lens',len(s))
indexes = [i for i, x in enumerate(s) if x == "B"]
ideal = sorted([len(s) - i - 1 for i in range(len(indexes))])
# print(indexes)
# print(ideal)
for i in range(len(indexes)):
    count += ideal[i] - indexes[i]
print(count)

s = list(eval(input()))
w = [i for i in range(len(s)) if s[i] == "W"]
ideal = [j for j in range(s.count("W"))]
print((sum([i - j for i, j in zip(w, ideal)])))

-count = 0 -# print('lens',len(s)) -indexes = [i for i, x in enumerate(s) if x == "B"] -ideal = sorted([len(s) - i - 1 for i in range(len(indexes))]) -# print(indexes) -# print(ideal) -for i in range(len(indexes)): -    count += ideal[i] - indexes[i] -print(count) +w = [i for i in range(len(s)) if s[i] == "W"] +ideal = [j for j in range(s.count("W"))] +print((sum([i - j for i, j in zip(w, ideal)])))