S = list(eval(input()))

N = len(S)

left = [0] * N

right = [0] * N



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]



# if S[N -1] == 'W':

#     right[N - 1] = 1

# for i in range(N - 2, -1, -1):

#     if S[i] == 'W':

#         pass



ans = 0

for i in range(N):

    if S[i] == 'W':

        ans += left[i]



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)
left = [0] * N
right = [0] * N
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]
# if S[N -1] == 'W':
#     right[N - 1] = 1
# for i in range(N - 2, -1, -1):
#     if S[i] == 'W':
#         pass
ans = 0
for i in range(N):
    if S[i] == "W":
        ans += left[i]
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)

-right = [0] * N +ans = 0 -# if S[N -1] == 'W': -#     right[N - 1] = 1 -# for i in range(N - 2, -1, -1): -#     if S[i] == 'W': -#         pass -ans = 0 -for i in range(N): -    if S[i] == "W":