Problem:
 Score : 300 points    Problem Statement There are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)
The state of each piece is represented by a string S of length N .
If S_i= B , the i -th piece from the left is showing black;
If S_i= W , the i -th piece from the left is showing white.  Consider performing the following operation:   Choose i ( 1 \leq i < N ) such that the i -th piece from the left is showing black and the (i+1) -th piece from the left is showing white, then flip both of those pieces. That is, the i -th piece from the left is now showing white and the (i+1) -th piece from the left is now showing black.   Find the maximum possible number of times this operation can be performed.      Constraints  1 \leq |S| \leq 2\times 10^5  S_i= B or W         Input Input is given from Standard Input in the following format:  S       Output Print the maximum possible number of times the operation can be performed.        Sample Input 1 BBW      Sample Output 1 2  The operation can be performed twice, as follows:   Flip the second and third pieces from the left.  Flip the first and second pieces from the left.        Sample Input 2 BWBWBW      Sample Output 2 6

Solution (Python):
S = input()

cntB = 0
cntW = 0
ans = 0

idx = 0

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

Solution (Python):
def tyousei(a):
    tyousei_ = [0]
    for i in range(a):
        tyousei_.append(tyousei_[i]+i+1)
    return tyousei_[a]

s = input()
count = 0
length = 0

for i in range(len(s)):
    if s[i]=='B':
        length = length + i
        count = count + 1
    
print((len(s)-1)*count-length-tyousei(count-1))

Solution (Python):
s=input()
r=len(s)
bs=[]
for i in range(r):
  if s[i]=='B':
    bs.append(i+1)
l=len(bs)
ans=0
for i in range(l):
  ans+=r-bs[i]-(l-i-1)
print(ans)

Solution (Python):


s = input()
ans = 0
wc = 0
for si, sv in enumerate(s):
    if sv == "W":
        ans += si - wc
        wc += 1
print(ans)

Solution (Python):
S = input()
ans = 0
b = 0
for s in S:
    if s == "B":
        b += 1
    else:
        ans += b

print(ans)

Solution (Python):
wb = input()
li = [i for i in wb]
b = 0
count = 0
for i in li:
    if i =='B':
        b+=1
    else:
        count += b
print(count)

Solution (Python):


S = input()
numB = 0
answer = 0
for c in S:
    if c == 'B':
        numB += 1
    else:
        answer += numB
print(answer)

Solution (Python):
S = list(input())
ans = 0
N = len(S)
flag = False
cntb = 0
cnt = 0
for i in range(N):
    if S[i] == 'B':
        cntb += 1
    elif S[i] =='W':
        cnt += cntb
        
print(cnt)

Solution (Python):
S = input()
cnt = 0
mvcnt = 0
for x in S:
  if x == "B":
    cnt += 1
  else:
    mvcnt += cnt
print(mvcnt)

Solution (Python):
ans = 0
b = 0

for s in input():
    if s == 'B':
        b += 1
    else:
        ans += b

print(ans)

Solution (Python):
S = input()
ans = 0
tmp = 0

for i in S:
    if i == 'W':
        ans += tmp
    else:
        tmp += 1

print(ans)

Solution (Python):
S = input()

c, last_w = 0, 0
for i, s in enumerate(S):
	if "W" == s:
		c += i - last_w
		last_w += 1
print(c)

Solution (Python):
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint

import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    
    x = root(x)
    y = root(y)
    if x == y:
        return
    
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  
        return x
    else:
        node[x] = root(node[x])  
        return node[x]
def dfs(v):
    
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  
            continue
        if visited[v2] == True:  
            continue
        dfs(v2)


s = input()[::-1]
index = s.find('W')
s = s[index:]
cnt = 0
b_cnt = 0
for i, b in enumerate(s):
    if b == 'B':
        cnt += i - b_cnt
        b_cnt += 1
print(cnt)

Solution (Python):
S = input()

B_nums = []
for s in S:
    if len(B_nums) == 0:
        B_nums.append(1 if s == "B" else 0)
    else:
        B_nums.append((B_nums[-1] + 1) if s == "B" else B_nums[-1])

res = 0
for index, s in enumerate(S):
    if s == "W":
        res += B_nums[index]

print(res)

Solution (Python):
S = input()

B_num = S.count("B")
W_num = S.count("W")

B_start = W_num 

res = 0
for i in range(B_start + 1):
    if i == len(S):
        break
    if S[i] == "B":
        res += B_start - i
        B_start += 1
        while(B_start < len(S) and S[B_start] == "B"):
            B_start += 1

print(res)

Solution (Python):
s = str(input())

len_s = len(s)
cnt = 0
ans = 0
for i in range(1,len_s+1):
    if s[-i] == 'B':
        ans += cnt
    else:
        cnt += 1
print(ans)

Solution (Python):
S=input()
t=0
ans=0
for i in S:
    if i=="B":
        t+=1
    else:
        ans+=t
print(ans)

Solution (Python):
S = input()
cnt = 0
ans = 0
for i in range(1, len(S)+1):
    if S[-i] == 'W':
        cnt += 1
    else:
        ans += cnt
print(ans)

Solution (Python):
a = list(input())

b = 0
c = 0

for i in a:
  if i == 'W':
    b += c
  else:
    c += 1
    
print(b)

Solution (Python):
s = input()

cnt = 0
black = 0
for string in s:
  if string == "B":
    black += 1
  else:
    cnt += black

print(cnt)

Solution (Python):
s = input().rstrip()

ans = 0
w_num = 0
for i, c in enumerate(s):
    if c == "W":
        ans += i - w_num
        w_num += 1

print(ans)

Solution (Python):

"""
A - Irreversible operation
https://atcoder.jp/contests/agc029/tasks/agc029_a

"""
import sys


def solve(S):
    ans = 0
    black = S.count('B')
    white = S.count('W')
    for ch in S[::-1]:
        if ch == 'B':
            black -= 1
        else:
            ans += black
    return ans


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
S = input()

white = [i for (i, s) in enumerate(S) if s == 'W']
ideal = [i for i in range(len(white))]

print(sum(w - i for (w, i) in zip(white, ideal)))

Solution (Python):
s = input()
n = len(s)

white, black, ans = 0, 0, 0
for i in range(1, n):
    if s[-i] == 'W':
        black = 0
        white += 1
        if s[-i-1] == 'B':
            if i == n-1:
                black += 1
                ans += black*white
    else:
        black += 1
        if s[-i-1] == 'B':
            if i == n-1:
                black += 1
                ans += black*white
        else:
            ans += black*white
print(ans)

Solution (Python):
S=input()
ans=0
w=0
for i in range(len(S)):
	if S[-(i+1)]=='W':
		w+=1
	else:
		ans+=w
print(ans)

Solution (Python):
S = input()
l = len(S)
ans = 0
for i in range(len(S)-1, -1, -1):
    if S[i] == "B":
        ans += l-1-i
        l -= 1
print(ans)

Solution (Python):
s=input()
b=0
ans=0
for i in range(len(s)):
    if s[i]=="B":b+=1
    else:ans+=b
print(ans)

Solution (Python):
s = input()

cb = 0
m = 0
for c in s:
    if c == "W":
        m += cb
    else:
        cb += 1

print(m)

Solution (Python):
s = 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)

Solution (Python):
S = input()

count = 0
out = 0
for cur_i, s in enumerate(S):
    if s == "W":
        out += (cur_i - count)
        count += 1

print(out)

Solution (Python):
s = input()

ans = 0
ichi = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += ichi
    else:
        ichi += 1
print(ans)

Solution (Python):
S = list(input())
N = len(S)
count = 0
num = 0

for i in range(N):
    if S[i] == 'W':
        num += 1
        count = count + i + 1 - num

print(count)

Solution (Python):
S = input()
black_count = 0
counter = 0
for i, c in enumerate(reversed(S)):
    if c == 'B':
        counter += i - black_count
        black_count += 1
print(counter)

Solution (Python):
import re

S = input()
Bs = S.count('B')
Ws = len(S) - Bs
res = 0

ite = re.finditer('W', S)
for i, j in enumerate(ite):
  res += (j.start() - i)
  
print(res)

Solution (Python):
s = input()
l = len(s)
a = []
for i, ss in enumerate(s):
    if ss == "W":
        a.append(i+1)
w_num = s.count("W")
sum_a = (w_num * (w_num + 1)) // 2
ans = sum(a) - sum_a
print(ans)

Solution (Python):
S=input()
ans=0
tmp=0
for s in S:
  if s=='B':
    tmp+=1
  else:
    ans+=tmp

print(ans)

Solution (Python):

x=[]
S=str(input())
for i in range(len(S)):
    if S[i]=="W":
        x.append(i+1)

for j in range(len(x)):
    x[j]=x[j]-j-1
print(sum(x))

Solution (Python):
s=input()
ans=0
count=0
for x in s:
  if x=="B":
    count+=1
  else:
    ans+=count
print(ans)

Solution (Python):
s=input()
wpos=[]
ans=0
for i in range(len(s)):
  if s[i]=='W':
    wpos.append(i)
for i in range(len(wpos)):
  ans+=(wpos[i]-i)
print(ans)

Solution (Python):
import re

s = input()
a = [m.start() for m in re.finditer("W", s)]

ans = 0
for i, e in enumerate(a):
    ans += e - i

print(ans)

Solution (Python):
a,s,b=0,input(),0
for i in range(len(s)):
  if s[i]=="W":a+=i;b+=1
print(a-((b*(b-1))//2))

Solution (Python):
a,s,b=0,input(),0
for i in range(len(s)):a+=i*(s[i]=="W");b+=(s[i]=="W")
print(a-((b*(b-1))//2))

Solution (Python):
s = input()

if s[0]=="W":
    l = [1]
else:
    l = [0,1]

for i in range(1,len(s)):
    if s[i]==s[i-1]:
        l[-1]+=1
    else:
        l.append(1)

rightw = sum(l[2::2])

ans = 0

for i in range(len(l)//2):
    ans += l[2*i+1]*rightw
    if i!=len(l)//2-1:
        rightw -= l[2*i+2]

print(ans)

Solution (Python):
S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)

Solution (Python):
S = input()

total = 0
count = 0
for i in range(len(S)):
    if S[i] == 'W':
        total += i - count
        count += 1

print(total)

Solution (Python):
s = input()
count=0
answer=0
for i in range(len(s)):
  if s[i]=="W":
    answer=answer+i-count
    count=count+1
    
print(answer)

Solution (Python):
in_seq = raw_input()
listAdd = 0
cnt = 0
cnt_W = 0
for stone in in_seq:
  if stone == "W":
    
    cnt_move = cnt - cnt_W
    listAdd += cnt_move
    cnt_W += 1
  cnt += 1
print listAdd

Solution (Python):
osero = input();
len = len(osero);
con_b = 0;
con = 0;
for i in range(0,len):
	if osero[i]=='B':
		con_b = con_b + 1;
	if osero[i] =='W':
		con = con + con_b;
print(con)

Solution (Python):
S=input()

position = 0
answer = 0
for i, s in enumerate(S):
  if s=='W':
    answer += i-position
    position += 1
print(answer)

Solution (Python):
S = input()
N = len(S)
sum = 0
cnt = 0
for i in range(N):
  if S[i] == 'B':
    cnt += 1
  else:
    sum += cnt
print(sum)

Solution (Python):



S = [x for x in input()]

min = 0
count = 0
for i, x in enumerate(S):
    if x == 'W':
        count += i - min
        min += 1
        
print(count)

Solution (Python):
S=input()
ans=0
cnt=0
for i, s in enumerate(S):
    if s=='W':
        cnt+=1
        ans+=i-cnt+1
 
print(ans)

Solution (Python):
S=input()
ans=0
cnt=0
for i, s in enumerate(S):
    if s=='W':
        cnt+=1
        ans+=i-cnt+1

print(ans)

Solution (Python):
s = list(input())
count = 0
ans = 0
for i in range(len(s)):
    if s[i] =="W":
        ans += i-count
        count +=1
print(ans)

Solution (Python):
S = input()[::-1]
w = 0
res = 0
for s in S:
	if s == 'W':
		w += 1
	else:
		res += w
print(res)

Solution (Python):
s = input()

cnt = 0
result = 0
for v in reversed(s):
    if v == "W":
        cnt += 1
    else:
        result += cnt
print(result)

Solution (Python):
s = input()

res = 0
W_cnt = 0
for x in s[::-1]:
    if x == "W":
        W_cnt += 1
    else:
        res += W_cnt
print(res)

Solution (Python):
s = str(input())
n = len(s)

count = 0 
for i in range(n):
    if s[i] == 'B':
        count = count + 1

ans = 0
c = n - count
for i in range(n):
    if s[i] == 'B':
        ans = ans + (c - i)
        c = c + 1

print(ans)

Solution (Python):
import numpy as np
s = np.array(list(input()))

ind = np.array(np.where(s=='B'))

len_ind=ind.shape[1]

len=s.shape[0]

dist=np.arange(len-len_ind,len)

ans=np.sum(dist-ind)
print(ans)

Solution (Python):
txt = input()
txt_list = list(txt)

count = 0
n_b = 0
n_w = 0
i = 0
for i in range(len(txt_list)):
    if txt_list[i] == 'W':
        n_w += 1
    if (i>=1 and txt_list[i-1] == 'W' and txt_list[i] == 'B') or (i==len(txt_list)-1 and txt_list[i] == 'W'):
        count += n_b * n_w
        n_w = 0
    if txt_list[i] == 'B':
        n_b += 1

print(count)

Solution (Python):
txt = input()
txt_list = list(txt)

num = 0
count = 0
for i in range(len(txt)):
    if txt_list[i] == 'W':
        count += i-num 
        num += 1

print(count)

Solution (Python):
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Solution (Python):
S = list(input())
B = 0
ans = 0

for i in range(len(S)):
    if S[i] == 'B':
        B += 1
    else:
        ans += B

print(ans)

Solution (Python):
S = input()
b = 0
ans = 0
for c in S:
    if c == 'B':
        b += 1
    else:
        ans += b
print(ans)

Solution (Python):
S = input()
white = 0
for i in range(len(S)):
  if S[i] == 'W':
    white += 1
cnt = 0
ans = 0
for i in range(len(S)):
  if S[i] == 'W':
    ans += i-cnt
    cnt += 1
print(ans)

Solution (Python):
S = list(input())

w_count = 0
ans = 0
for i in range(len(S)):
  if(S[i] == 'W'):
    ans += i - w_count
    w_count += 1
print(ans)

Solution (Python):
s = input()
n = len(s)
count = 0
m = 0
for i in range(n):
    if s[i] == 'W':
        count += i - m
        m += 1
print(count)

Solution (Python):
s=input()
plus=0
ans=0
for i in range(len(s)):
    if s[-1-i]=="W":
        plus+=1
    else:
        ans+=plus
print(ans)

Solution (Python):

s = list(input())
ans = 0
b = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i - b
        b += 1
print(ans)

Solution (Python):
S = input()
B = 0
count = 0
for s in S:
    if s == "B":
        B += 1
    elif s == "W":
        count += B
print(count)

Solution (Python):
count,ans = 0,0
s=input()
for i,c in enumerate(s):
  if c == 'W':
    ans += i - count
    count += 1
print(ans)

Solution (Python):
S = input()

ans = 0
white = [0]*len(S)
w = 0

for i in range(len(S)):
  if S[i] == "W":
    white[w] += i
    w += 1
for i in range(len(S)):
  if white[i] > 0:
    ans += white[i]-i
print(ans)

Solution (Python):
S = input()
num, cnt = 0, 0
for k in range(len(S)):
  if S[k] == 'B':
    num += 1
  else:
    cnt += num
print(cnt)

Solution (Python):
"""AtCoder"""

S = input()

ans = 0
tmp = 0

for i in range(len(S)):
    if S[i] == 'W':
        ans += i - tmp
        tmp += 1

print(ans)

Solution (Python):
S = input()

counter = 0
ans = 0

for index, char in enumerate(S):
    if(char == "W"):
        ans += index - counter
        counter += 1

print(int(ans))

Solution (Python):
s = input()
pos = 0
ans = 0
for i in range(len(s)):
    if s[i]=="W":
        ans += i-pos
        pos += 1
print(ans)

Solution (Python):
s = input()

ans = 0
b = 0
for ss in s:
    if ss == 'W':
        ans += b
    else:
        b += 1
print(ans)

Solution (Python):
S = list(input())
B = 0
W = 0
for i in range(len(S)):
    if S[i] == 'B':
        B += 1
    else:
        W += 1
Num = 0
Count = 0
for i in range(len(S)):
    if S[i] == 'W':
        Count += (i-Num)
        Num += 1
print(Count)

Solution (Python):
st = input()
bcount = 0
ans = 0
for i in range(len(st)):
    if st[i] == "B":
        bcount+=1
    else:
        ans += bcount
print(ans)

Solution (Python):
s = input()
l = len(s)
a = [0 for i in range(l)]
cur = 0
for i, ele in enumerate(s[::-1]):
  a[i] = cur
  if ele =="W":
    cur += 1

ans = 0
for i in range(l):
  if s[i]=="B":
    ans += a[l-i-1]
print(ans)

Solution (Python):
def main29():
    S = input()
    count = 0
    start = False
    tmp = 0
    W_count = 0

    for i in range(len(S)):
        if S[i] == "W":
            if not start and i > 0:
                if S[i-1] == "B":
                    count += i - W_count
                    tmp = i
                    start = True
            else:
                count += i - W_count
                tmp = i
            W_count += 1

    print(count)

main29()

Solution (Python):
s=input()
a=[]
b=0
w=0
for i in s:
  if i =='B':
    a.append(0)
    b+=1
  else:
    a.append(1)
    w+=1
A=len(a)
cnt=0
for i in range(A):
  if a[i]==1:
    cnt+=i
for i in range(w):
  cnt-=i
print(cnt)

Solution (Python):
string = input()
length = len(string)
bnum = len([x for x in string if x == "B"])
ans = 0
for i in range(length):
    if string[i] == "B":
        ans += length-i-1
        
ans = ans - int(bnum*(bnum-1)/2)
print(ans)

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

S = S()
result = 0
w_count = 0
for sidx, s in enumerate(S[::-1]):
    if s == "W":
        w_count += 1
    else:
        result += w_count








print(result)

Solution (Python):
s = input()
w = 0
b = 0
ans = 0
slist = []
for i in s:
    slist.append(i)
slist.reverse
for i in slist:
    if i == "B":
        w += 1
    else:
        b += 1
        ans += w

print(ans)

Solution (Python):
s=list(str(input()))
counter=0
ans=0
for i in range(len(s)):
    if s[i]=="W":
        ans+=i-counter
        counter+=1
    else:
        pass
print(ans)

Solution (Python):
S = str(input())
S_ = [idx for idx, x in enumerate(S) if x=='W']
print(sum(S_) - sum([_ for _ in range(len(S_))]))

Solution (Python):
cnt = ans = 0
for c in input():
  if c is 'W':
    ans += cnt
  else:
    cnt += 1
print(ans)

Solution (Python):
cnt = ans = 0
for c in input():
  if c is 'W':
    ans += cnt
  else:
    cnt += 1
print(ans)

Solution (Python):
s = input()
t = 0
c = 0
for i in range(len(s)):
  if s[i] == "W":
    t += i
    c += 1
print(t-c*(c-1)//2)

Solution (Python):
S = input()
l = len(S)
a = [l-i for i,c in enumerate(S) if c=="B"]
b = len(a)
print(sum(a) - b*(b+1)//2)

Solution (Python):
S = input()
w_count = [0]*len(S)
if S[0] == 'W':
    w_count[0] = 1

res = 0
for i in range(1,len(S)):
    if S[i] == 'W':
        res += i - w_count[i-1]
        w_count[i] = w_count[i-1] + 1
    else:
        w_count[i] = w_count[i-1]


print(res)

Solution (Python):
S = input()
ans = 0
cnt = 0
for s in S:
    if s == "B":
        cnt += 1
    else:
        ans += cnt
print(ans)

Solution (Python):
S = input()
N = len(S)






dp = [0] * (N + 1)
ans = 0
for i in range(1, N + 1):
    if S[i-1] == 'B':
        dp[i] = dp[i-1] + 1
    else:
        dp[i] = dp[i-1]
        ans += dp[i]

print(ans)

Solution (Python):
S = list(input())
move = 0
ans = 0
for i in range(len(S)):
	if S[i] == 'B':
		move += 1
	else:
		ans += move
print(ans)

Solution (Python):
N = list(input())
b_n = N.count("B")
point = 0
for i in range(len(N)):
    if N[i] == "B":
        point += i
future_point = (b_n * (len(N) - 1 - b_n + 1 + len(N) - 1)) // 2
print(future_point - point)

Solution (Python):
s,t,a=input(),0,0
for c in s:
  if c is 'B':
    t+=1
  else:
    a+=t
print(a)

Solution (Python):
s=list(str(input()))
count=0
ans=0
for i in s:
  if i == "B":
    count+= 1
  else:
    ans+= count
print(ans)

Solution (Python):
import sys

S = list(sys.stdin.readline().rstrip())
cnt_w = S.count('W')
loc_w = [i+1 for i,c in enumerate(S) if c == 'W']
print(sum(loc_w)-cnt_w*(cnt_w+1)//2)

Solution (Python):

s=input()
answer=0
counter=0
for i in range(len(s)-1,-1,-1):
    if s[i]=="B":
        answer += len(s)-i-1-counter
        counter += 1
print(answer)

Solution (Python):
S = input()
ans = 0
count = 0
for i in range(len(S)-1, -1, -1):
    if S[i] == "B":
        ans += len(S)-i-1-count
        count += 1
 
print(ans)

Solution (Python):
s=input();x=[k for k,v in enumerate(s)if v=="W"];print(sum(x)-sum(range(len(x))))

Solution (Python):
a=b=0
for s in input():a+=b*(s>'B');b+=s<'W'
print(a)

Solution (Python):
s=input();print(sum(i for i in range(len(s))if s[i]=="W")-sum(range(s.count("W"))))

Solution (Python):
s=input()
ans=0
count=0
for i in range(len(s)):
    if s[i]=="W":
        ans+=i-count
        count+=1
print(ans)

Solution (Python):
S = input()
ans = 0
count = 0
for i in range(len(S)-1, -1, -1):
    if S[i] == "B":
        ans += len(S)-i-1-count
        count += 1
 
print(ans)

Solution (Python):

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = (input_raw[0])
    count = 0
    w_count = 0
    for i in range(len(S)):
        if S[i] == "W":
            count += (i - w_count)
            w_count += 1
    print count

if __name__ == '__main__':
    main()

Solution (Python):
s=list(input())
ans=0
wf=0
bf=0
for i in range(len(s)):
    if s[i]=='W':
        ans+=i
        wf+=1
    else:
        bf=1
if wf==0 or bf==0:
    print(0)
else:
    print(ans-wf*(wf-1)//2)

Solution (Python):
s = list(str(input()))
count = 0
ans = 0
for i in s:
    if i == "B":
        count += 1
    else:
        ans += count
print(ans)

Solution (Python):
s = input()
n = len(s)
if n <= 1:
  print(0)
  exit()
else:
  left = 0
  ans = 0
  for i in range(n):
    if s[i] == 'W':
      left+= 1
      ans += (i+1)-left
      
print(ans)

Solution (Python):
X = input()

ans = 0
ind = 0
for i in range(len(X)):
    if(X[i] == 'W'):
        ans += i-ind
        ind += 1
        
print(ans)

Solution (Python):
c=input()
n=0
ans=0
for x in c:
  if x=='B':
    n+=1
  else:
    ans+=n
print(ans)

Solution (Python):
c=input()
n=0
ans=0
for i in range(len(c)-1,-1,-1):
  if c[i]=='W':
    n+=1
  else:
    ans+=n
print(ans)

Solution (Python):
S = input()
 
arr = [0 if s == "W" else 1 for s in S]
sorted_arr = sorted(arr)
  
state = sum([arr[i] * i for i in range(len(S))])
final_state = sum([sorted_arr[i] * i for i in range(len(S))])
 
print(final_state - state)

Solution (Python):
def main():
    s=input()
    ans=0
    cnt=0
    for i in range(len(s)):
        if(s[i]=='W'):
            ans+=i-cnt
            cnt+=1
    print(ans)
if __name__=="__main__":
    main()

Solution (Python):
from functools import reduce
S = input()
ans = reduce(
    lambda acc, s: (acc[0] + acc[1], acc[1]) if s == 'B' else (acc[0], acc[1] + 1),
    reversed(S),
    (0, 0)
)[0]
print(ans)

Solution (Python):
S = input()

ans = 0
black = 0
for a in S:
    if a == 'B':
        black += 1
    else:
        ans += black
print(ans)

Solution (Python):
S= input()
b = 0
ans = 0
for i in S:
  if i =='W':
    ans+=b
  else:
    b+=1
print(ans)

Solution (Python):
s = list(input())

mode = 0
count = 0

ans = 0

for c in s:
    if mode == 0:
        if c == 'W':
            continue
        else:
            mode = 1
            count = 1
    else:
        if c == 'B':
            count += 1
        else:
            ans += count

print(ans)

Solution (Python):
s=list(input())
w=[i for i in range(len(s)) if s[i]=="W"]
ideal=[j for j in range(s.count('W'))]
print(sum([i-j for i,j in zip(w,ideal)]))

Solution (Python):
s = input()
n = len(s)

ans = 0
num_B = 0
for c in s:
    if c == "B":
        num_B += 1
    else:
        ans += num_B
print(ans)

Solution (Python):
S = input()

ans = 0
num_w = 0
for i in range(len(S)):
    s = S[i]
    if s=='W':
        ans += i - num_w
        num_w += 1

print(ans)

Solution (Python):
S = input()
ans = 0
b = 0
for s in S:
    if s == 'W':
        ans += b
    else:
        b += 1

print(ans)

Solution (Python):
s = input()
count = 0
ans = 0
for i in s:
    if i == "B":
        count += 1
    else:
        ans += count
print(ans)

Solution (Python):
S = input()
ans = 0
tmp = 0
for i in range(len(S)):
  if S[i] == 'W':
    ans+=i-tmp
    tmp+=1
print(ans)

Solution (Python):
s=input()
ans=0
count=0 if s[0]=="B" else 1
for i in range(1,len(s)):
        if s[i]=="W":
            ans+=i-count
            count+=1
print(ans)

Solution (Python):
s = list(input())
cnt = 0
cnt_B = 0

for i in range(len(s)):
    if s[i] == 'B':
        cnt += len(s) - (i + 1 + cnt_B)
        cnt_B += 1
        
print(cnt)

Solution (Python):
S = [1 if(_ =="B") else 0 for _ in input()]+[1]
ans = 0
if(S.index(1) == len(S)-1):
    print(0)
else:
    S.pop(-1)
    first = S.index(1)
    count = first
    start = first
    for s in S[start:]:
        if(s == 0):
            ans += count -first
            first += 1
        count += 1
    print(ans)

Solution (Python):
S = input()
indexes = [i for i, x in enumerate(S) if x == "W"]
print(sum([x-i for i, x in enumerate(indexes)]))

Solution (Python):
s = str(input())

wcount=0
w_place=0
for i in range(len(s)):       
    if s[i]=="W":
        wcount+=1
        w_place+=i+1
print(int(w_place-(1+wcount)*wcount/2))

Solution (Python):
S = input()

count = 0
for i in range(len(S)):
    if S[i] == 'W':
        continue
    else:
        break
S = S[i:]

count = 0
score = 0
for i in range(len(S)):
    if S[i] == 'W':
        score += (i - count)
        count += 1
print(score)

Solution (Python):
S=input()[::-1]
ans,tmp=0,0
for i in S:
  if i=='W':
    tmp+=1
  else:
    ans+=tmp
print(ans)

Solution (Python):


S = list(input())

count = 0

count_b = 0
for s in S:
  if s == 'B':
    count_b += 1
  else:
    count += count_b
print(count)

Solution (Python):
S = input()
ans, tmp = 0, 0
for s in S[::-1]:
  if s == 'B':
    ans += tmp
  else:
    tmp += 1
print(ans)

Solution (Python):
import itertools
import numpy as np
import sys

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)
num = s.find("B")

cnt = 0
ans = 0
for i in range(max(0,num-1),N):
    if s[i] == "B":
        cnt += 1
    else:
        ans += cnt

print(ans)

Solution (Python):
S = list(input())

cnt = 0
Ans = 0
for i in S:
  if i == "B":
    cnt += 1
  else:
    Ans += cnt

print(Ans)

Solution (Python):
s = input()

ans = 0
count = 0
for i in range(len(s)):
    if s[i] == 'W':
        ans += i - count
        count += 1

print(ans)

Solution (Python):
S = input()
res = 0
count = 0
for i in range(len(S)):
    if S[i] == 'B':
        count += 1
    if S[i] == 'W':
        res += count
       
print(res)

Solution (Python):
s=list(input())
ans=0
a=s.count("B")
for i in range(len(s)):
    if s[i]=="B":
        ans+=i
b_cnt=(s.count("W")+(len(s)-1))*s.count("B")//2
print(int(b_cnt-ans))

Solution (Python):
S = input()
Ws = []
for i in range(len(S)):
    if S[i] == 'W': Ws.append(i)
def func(n): return (n+1)*n//2
print(sum(Ws)-func(len(Ws)-1))

Solution (Python):
S=input()
k=0
ans=0
for i in range(len(S)):
  if S[i]=="W":
    ans+=i-k
    k+=1
print(ans)

Solution (Python):
ss=input()
ans=0
b_count=0
for s in ss:
    if s=='B': b_count+=1
    if s=='W': ans+=b_count
print(ans)

Solution (Python):
from sys import stdin
N=(stdin.readline().rstrip())
N=list(N)
cnt=0
ans=0
for i in N:
    if i=="B":
        cnt+=1
    else:
        ans+=cnt
print(ans)

Solution (Python):
s = input()

acc = 0

for i in range(len(s)):
  if s[i] != 'W':
    break

for j in range(i, len(s)):
  if s[j] == 'W':
    acc += j - i
    i += 1

print(acc)

Solution (Python):



def main():
    S = list(input())
    count = 0
    w_offset = 0
    for i in range(len(S)):
        if S[i] == "W":
            count += i - w_offset
            w_offset += 1

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
s=list(input())
n=len(s)
total_b=0
cnt=0
total=0
for i in range(n):
    if s[i]=="B":
        total_b+=i
        cnt+=1
for i in range(n-cnt,n):
    total+=i
print(total-total_b)

Solution (Python):
N = input()
cnt1 = 0
for x in N:
  if x == 'B':
    cnt1 += 1
N = N[::-1]
ans =  0
cnt2 = 0
for i in range(len(N)):
  if N[i] == 'B':
    ans += i - cnt2
    cnt2 += 1
print(ans)

Solution (Python):
import sys
S=sys.stdin.readline()
l=len(S)
w_idx=0
cnt=0
for i in range(l):
    if S[i]=='W':
        cnt+=i-w_idx
        w_idx+=1
print(cnt)

Solution (Python):
S=input()
l=len(S)
w_idx=0
cnt=0
for i in range(l):
    if S[i]=='W':
        cnt+=i-w_idx
        w_idx+=1
print(cnt)

Solution (Python):
ar = list(input())
wc = ar.count("W")
count = 0
for i in range(len(ar)):
    if ar[i] == "B":
        count += wc
    else:
        wc -= 1
print(count)

Solution (Python):
hoge=input()
ans=0
count=0
white=0
for i in hoge:
  
  if(i=="W"):
    ans+=count - white
    white+=1
    
  count+=1
  
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

s = input()
l = [0]*(len(s))
if s[0] == 'B':
    l[0] = 1
ans = 0
for i, c in enumerate(s[1:]):
    if c == 'B':
        l[i+1] = 1
    elif c == "W":
        ans += l[i]
    l[i+1] += l[i]
print(ans)

Solution (Python):
s = list(str(input()))
sm = [1 if s[i] == 'B' else 0 for i in range(len(s))]
smr = list(reversed(sm))
t =[]
for i in range(len(s)):
    if smr[i] == 1:
        t.append(i)
u = [i for i in range(len(t))]
v = [t[i] - u[i] for i in range(len(t))]
ans = sum(v)
print(ans)

Solution (Python):
S = input()
L = [0]
for i in S[::-1]:
    if i == "W":
        L.append(0)
    if i == "B":
        L[-1] += len(L)-1 

print(sum(L))

Solution (Python):
import re
import sys

line = next(map(str.strip, sys.stdin))

count = 0
nb_bs = 0
for i, c in enumerate(line):
    if c == 'W' and nb_bs > 0:
        count += nb_bs
    elif c == 'B':
        nb_bs += 1

print(count)

Solution (Python):
a=list(input())
l=[]
for i in range(1,len(a)+1):
  if a[-i]=="B":
    l.append(i)
m=len(l)
print(sum(l)-((m+1)*m)//2)

Solution (Python):
S = input()
count_ans = 0
count_B = 0
right_W = 0
for i, c in enumerate(S):
	if c == "W":
		count_ans += count_B
	else:
		count_B += 1
print(count_ans)

Solution (Python):

def countB(data):
    sum=0
    kosu=0
    for i in range(len(data)):
        if data[i]=="B":
            kosu=kosu+1
            sum=sum+i
    return[sum,kosu]

text=input()
S=[]
N=len(text)
for i in range(N):
    S.append(text[i])
result=countB(S)
x=result[1]
Ans=int((2*N-x-1)*x/2-result[0])
print(Ans)

Solution (Python):
a=b=0
for s in input():
 if s>'B':a+=b
 else:b+=1
print(a)