S = list(eval(input()))

N = len(S)

left = [0] * N



ans = 0

if S[0] == 'B':

    left[0] = 1

for i in range(1, N):

    if S[i] == 'B':

        left[i] = left[i - 1] + 1

    else:

        left[i] = left[i - 1]

        ans += left[i]



print (ans)
S = list(eval(input()))

N = len(S)



ans = 0

# if S[0] == 'B':

#     tmp = 1

# else:

#     tmp = 0



tmp = 1 if S[0] == 'B' else 0



for i in range(1, N):

    if S[i] == 'B':

        tmp += 1

    else:

        ans += tmp



print (ans)
S = list(eval(input()))
N = len(S)
left = [0] * N
ans = 0
if S[0] == "B":
    left[0] = 1
for i in range(1, N):
    if S[i] == "B":
        left[i] = left[i - 1] + 1
    else:
        left[i] = left[i - 1]
        ans += left[i]
print(ans)

S = list(eval(input()))
N = len(S)
ans = 0
# if S[0] == 'B':
#     tmp = 1
# else:
#     tmp = 0
tmp = 1 if S[0] == "B" else 0
for i in range(1, N):
    if S[i] == "B":
        tmp += 1
    else:
        ans += tmp
print(ans)

-left = [0] * N -if S[0] == "B": -    left[0] = 1 +# if S[0] == 'B': +#     tmp = 1 +# else: +#     tmp = 0 +tmp = 1 if S[0] == "B" else 0 -        left[i] = left[i - 1] + 1 +        tmp += 1 -        left[i] = left[i - 1] -        ans += left[i] +        ans += tmp