S=input()[::-1]

n=len(S)

l=list(i for i in range(n) if S[i]=='B')

k=len(l)*(len(l)-1)//2

print((sum(l)-k))
l=[i for i,s in enumerate(input()[::-1])if s=='B']

m=len(l)

print((sum(l)-m*~-m//2))
S = input()[::-1]
n = len(S)
l = list(i for i in range(n) if S[i] == "B")
k = len(l) * (len(l) - 1) // 2
print((sum(l) - k))

l = [i for i, s in enumerate(input()[::-1]) if s == "B"]
m = len(l)
print((sum(l) - m * ~-m // 2))

-S = input()[::-1] -n = len(S) -l = list(i for i in range(n) if S[i] == "B") -k = len(l) * (len(l) - 1) // 2 -print((sum(l) - k)) +l = [i for i, s in enumerate(input()[::-1]) if s == "B"] +m = len(l) +print((sum(l) - m * ~-m // 2))