S = eval(input())



cntB = 0

cntW = 0

ans = 0



idx = 0



while idx < len(S):

    #print(idx,cntB,cntW,ans)

    if S[idx] == 'B':

        cntB += 1

        idx += 1

    else:

        while idx < len(S):

            if S[idx] == 'W':

                cntW += 1

                idx += 1

                #print(idx,cntW)

            else:

                ans += cntB*cntW

                cntW = 0

                break

        ans += cntB*cntW

        

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



cntB = 0

ans = 0



for ch in S:

    if ch == 'B':

        cntB += 1

    else:

        ans += cntB

print(ans)
S = eval(input())
cntB = 0
cntW = 0
ans = 0
idx = 0
while idx < len(S):
    # print(idx,cntB,cntW,ans)
    if S[idx] == "B":
        cntB += 1
        idx += 1
    else:
        while idx < len(S):
            if S[idx] == "W":
                cntW += 1
                idx += 1
                # print(idx,cntW)
            else:
                ans += cntB * cntW
                cntW = 0
                break
        ans += cntB * cntW
print(ans)

S = eval(input())
cntB = 0
ans = 0
for ch in S:
    if ch == "B":
        cntB += 1
    else:
        ans += cntB
print(ans)

-cntW = 0 -idx = 0 -while idx < len(S): -    # print(idx,cntB,cntW,ans) -    if S[idx] == "B": +for ch in S: +    if ch == "B": -        idx += 1 -        while idx < len(S): -            if S[idx] == "W": -                cntW += 1 -                idx += 1 -                # print(idx,cntW) -            else: -                ans += cntB * cntW -                cntW = 0 -                break -        ans += cntB * cntW +        ans += cntB