s=eval(input())

a=b=0

for i in range(len(s)):

  if s[i]=='B':

    b+=1

  else:

    a+=b

print(a)
a=b=0

for s in eval(input()):

 if s>'B':a+=b

 else:b+=1

print(a)
s = eval(input())
a = b = 0
for i in range(len(s)):
    if s[i] == "B":
        b += 1
    else:
        a += b
print(a)

a = b = 0
for s in eval(input()):
    if s > "B":
        a += b
    else:
        b += 1
print(a)

-s = eval(input()) -for i in range(len(s)): -    if s[i] == "B": +for s in eval(input()): +    if s > "B": +        a += b +    else: -    else: -        a += b