c=eval(input())

n=0

ans=0

for i in range(len(c)-1,-1,-1):

  if c[i]=='W':

    n+=1

  else:

    ans+=n

print(ans)
c=eval(input())

n=0

ans=0

for x in c:

  if x=='B':

    n+=1

  else:

    ans+=n

print(ans)
c = eval(input())
n = 0
ans = 0
for i in range(len(c) - 1, -1, -1):
    if c[i] == "W":
        n += 1
    else:
        ans += n
print(ans)

c = eval(input())
n = 0
ans = 0
for x in c:
    if x == "B":
        n += 1
    else:
        ans += n
print(ans)

-for i in range(len(c) - 1, -1, -1): -    if c[i] == "W": +for x in c: +    if x == "B":