s = eval(input())

ans = 0

ss = s.count('B')

sss = len(s)

index = -1

sum_s = 0



for i in range(ss):

    index = s.find('B', index+1)

    ans += sss-index-1

    sum_s += i

    

ans -= sum_s

print(ans)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



s = read().rstrip().decode()

cnt = 0

ans = 0

for i, ss in enumerate(s):

    if ss == 'W':

        ans += i - cnt

        cnt += 1

print(ans)

s = eval(input())
ans = 0
ss = s.count("B")
sss = len(s)
index = -1
sum_s = 0
for i in range(ss):
    index = s.find("B", index + 1)
    ans += sss - index - 1
    sum_s += i
ans -= sum_s
print(ans)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
s = read().rstrip().decode()
cnt = 0
ans = 0
for i, ss in enumerate(s):
    if ss == "W":
        ans += i - cnt
        cnt += 1
print(ans)

-s = eval(input()) +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10**7) +s = read().rstrip().decode() +cnt = 0 -ss = s.count("B") -sss = len(s) -index = -1 -sum_s = 0 -for i in range(ss): -    index = s.find("B", index + 1) -    ans += sss - index - 1 -    sum_s += i -ans -= sum_s +for i, ss in enumerate(s): +    if ss == "W": +        ans += i - cnt +        cnt += 1