from scipy.misc import comb

s = eval(input())

n = len(s)

r = s.count("B")

ans = 0

for i in range(r):

  ans += n-i



for i in range(len(s)):

  if s[i] == "B":

    ans -= i+1

  

print(ans)

s = eval(input())

n = len(s)

r = s.count("B")

ans = 0

for i in range(r):

  ans += n-i



for i in range(n):

  if s[i] == "B":

    ans -= i+1

  

print(ans)

from scipy.misc import comb

s = eval(input())
n = len(s)
r = s.count("B")
ans = 0
for i in range(r):
    ans += n - i
for i in range(len(s)):
    if s[i] == "B":
        ans -= i + 1
print(ans)

s = eval(input())
n = len(s)
r = s.count("B")
ans = 0
for i in range(r):
    ans += n - i
for i in range(n):
    if s[i] == "B":
        ans -= i + 1
print(ans)

-from scipy.misc import comb - -for i in range(len(s)): +for i in range(n):