S=eval(input())

Bcount=0

answer=0



for i in range(len(S)):

  if S[i]=='B':

    Bcount+=1

  if S[i]=='W':

    answer+=Bcount



print(answer)
S=eval(input())

Bcount=0

ans=0

for i in S:

  if i=='B':

    Bcount+=1

  if i=='W':

    ans+=Bcount

print(ans)
S = eval(input())
Bcount = 0
answer = 0
for i in range(len(S)):
    if S[i] == "B":
        Bcount += 1
    if S[i] == "W":
        answer += Bcount
print(answer)

S = eval(input())
Bcount = 0
ans = 0
for i in S:
    if i == "B":
        Bcount += 1
    if i == "W":
        ans += Bcount
print(ans)

-answer = 0 -for i in range(len(S)): -    if S[i] == "B": +ans = 0 +for i in S: +    if i == "B": -    if S[i] == "W": -        answer += Bcount -print(answer) +    if i == "W": +        ans += Bcount +print(ans)