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):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div

S = list(rs())
ans = 0
cnt = 0
for i in range(len(S)):
    if S[i] == 'B':
        cnt += 1
    if S[i] == 'W':
        ans += cnt
print(ans)

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]






s=list(input())
A=[]
for i in range(len(s)):
    if(s[i]=="W"):
        A.append(i)
k=0
i=0
for x in A:
    k+=(x-i)
    i+=1
print(k)

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

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

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007



def main():
	
	
	s = input()
	ret = 0
	pp_b = 0
	for c in s:
		if c == 'B':
			pp_b += 1
		else:
			ret += pp_b
	return ret
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

Solution (Python):
S = input()
B_count = 0
ans = 0
for c in S:
  if c == 'B':
    B_count += 1
  elif c == 'W':
    ans += B_count
print(ans)

Solution (Python):
S = input()
ans = 0
count = [0] * len(S)
tmp = 0
for i in reversed(range(len(S))):
    if S[i] == "B":
        count[i] = tmp
    else:
        tmp += 1

print(sum(count))

Solution (Python):
s = input()

w = []
for i in range(len(s)):
	if s[i] == "W":
		w.append(i)
res = 0

for i in range(len(w)):
	res += w[i] - i
print (res)

Solution (Python):
S = input().strip()

count = 0
suma = 0
for i in S:
  if i=="W":
    suma += count
  else:
    count += 1
print(suma)

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()
Nb = 0
count = 0
for i in range(len(S)):
  if S[i] == "B":
    Nb+=1
  else:
    count+=Nb
print(count)

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

counts = [0] * len(s)

for i, c in enumerate(s):
    prev = counts[i - 1] if i > 0 else 0
    if c == 'B':
        counts[i] = prev + 1
    else:
        counts[i] = prev

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

print(allowable)

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

print(ans)

Solution (Python):
def rle(t):
    tmp2, num, ans = t[0], 1, []
    for i in range(1, len(t)):
        if tmp2 == t[i]:
            num += 1
        else:
            ans.append([tmp2, num])
            tmp2 = t[i]
            num = 1
    ans.append([tmp2, num])
    return ans


S = input()

s = list(map(str, S))
l = rle(S)
now = [[], [], []]
for i in range(len(S)):
    if S[i] == 'B':
        now[0].append(i)
for j in range(len(now[0])):
    now[1].append(len(S) - len(now[0]) + j)
    now[2].append(now[1][j] - now[0][j])
print(sum(now[2]))

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    S = input()
    cnt_w = [0]*(len(S) + 1)
    for i in range(len(S) - 1,-1,-1):
        if S[i] == 'W':
            cnt_w[i] = cnt_w[i + 1] + 1
        else:
            cnt_w[i] = cnt_w[i + 1]
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            ans += cnt_w[i]
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
S=input()
S_list=list(S)
num_B = S.count('W')
count = 0
i = 0
for nb in range(num_B):
  while S_list[i] != 'W': i+=1
  count += i - nb
  S_list[nb],S_list[i]=S_list[i],S_list[nb]
  i+=1
print(count)

Solution (Python):
S = input()

cnt = 0
ans = 0

for i, s in enumerate(S[::-1]):
    if s =="B":
        ans += i - cnt
        cnt += 1
print(ans)

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

Solution (Python):
s=list(input())
ls=len(s)
ans=0
wpoint=[i for i, v in enumerate(s) if v=="W"]
wnum=len(wpoint)

for i in range(wnum):
    ans+=wpoint[i]-i
print(ans)

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
ans,target_index = 0,0
for i in range(len(S)):
    if S[i]=='W':
        ans += i-target_index
        target_index += 1
print(ans)

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

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

Solution (Python):
def integration(s):
  itg = [0]
  counter = 0
  for x in s:
    if x == "B":
      counter += 1
    itg.append(counter)
  return itg

def solve(itg, left, right):
  n = right-left
  if n <= 1:
    return 0
  mid = (left+right)//2
  a = solve(itg, left, mid)
  b = solve(itg, mid, right)
  res = a + b + (itg[mid]-itg[left])* \
    (right-mid-(itg[right]-itg[mid]))
  return res

s = input()
print(solve(integration(s), 0, len(s)))

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

Solution (Python):
S = input()
c = 0
current_B_counter = 0
for s in S:
    if s == "B":
        current_B_counter += 1
    if s == "W":
        c += current_B_counter

print(c)

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

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    ans = 0
    cnt = 0
    for s in S:
        if s == "B":
            cnt += 1
        else:
            ans += cnt
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
l = len (s)
se = set()
for i in range(l):
    if s[i]=='W':
        se.add(i)
n = len(se)

ans = sum(se) - n*(n-1)//2
print(ans)

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

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

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

ans = 0
x = len(s) - 1
for i in range(len(s) - 1, -1, -1):
    if s[i] == "B":
        ans += x - i
        x -= 1

print(ans)

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

Solution (Python):


def resolve():
    s=list(input())
    ans=[]
    cnt=0
    for i in s:
        if i=='B':
            cnt+=1
        else:
            ans.append(cnt)
    print(sum(ans))
resolve()

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

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

print(ans)

Solution (Python):
S=list(input())
total_count=0
b_count=0

for n in range(len(S)):
    if S[n]=='B':
        b_count+=1
    if S[n]=='W':
        total_count+=b_count
print(total_count)

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

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

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

ans = 0
bnum = 0

for i in range(N):
    if S[i] == "B":
        bnum += 1
    else:
        ans += bnum

print(ans)

Solution (Python):


S = input()

count = 0
ans = 0

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

print(ans)

Solution (Python):
S = input()
W = []
for i in range(len(S)):
    if S[i] == "W":
        W.append(i)

c=0
for i in range(len(W)):
    c+= W[i] - i

print(c)

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

print(ans)

Solution (Python):
s = input()

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

Solution (Python):
s=input()
l=len(s)
c=s.count('W')
ans='W'*c+'B'*(l-c)
w=0
b=0
for i in range(l):
    if i<=c-1 and s[i]!='W':
        w+=i
    if i>=c and s[i]!='B':
        b+=i
print(b-w)

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

print(ans)

Solution (Python):
S = input()
W = []
for i in range(len(S)):
    if S[i] == "W":
        W.append(i)

ans = 0
for i in range(len(W)):
    ans += W[i] - i

print(ans)

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

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

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

S=input()
wc=0
cnt=0
for i , s in enumerate(S):
    if s=='W':
        if i!=wc:
            cnt += i-wc
        wc += 1
    else:
        continue
print(cnt)

Solution (Python):
import numpy as np
S = np.array(list(map(str, input().rstrip())))

S[np.where(S=="W")] = 1
S[np.where(S=="B")] = 0
S = S.astype(int)
now = np.where(S==1)[0]
goal = np.arange(now.shape[0])

print((now - goal).sum())

Solution (Python):



import itertools

s_list = input()

gr = itertools.groupby(s_list)

num_b = 0
ans = 0

for key,group in gr:
    if key == "B":
        num_b += len(list(group))
    else:
        ans += num_b * len(list(group))
    
print(ans)

Solution (Python):
s = input()
opcount = 0
wcount = 0
bcount = 0
for i in range(len(s)):
  if s[i] == "B":
    bcount += 1
  else:
    if bcount>0:
      opcount += i-wcount
      wcount += 1
    else:
      wcount += 1
print(opcount)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    S = input()

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


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
B_index = [i for i,x in enumerate(s) if x == 'B']
a = sum(B_index)
b = 0
for i in range(len(s) - 1, len(s) - 1 - s.count('B'), -1):
    b += i
print(b-a)

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

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

Solution (Python):
import sys
s = sys.stdin.readline().strip()
print(sum([a-b for a, b in zip(list(range(s.count('W'), len(s))), [i for i, c in enumerate(s) if c == 'B'])]))

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

c = 0
ans = 0
for i in range(N):
  if S[-(i+1)] == "B":
    ans += i -c
    c += 1
print(ans)

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

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

count = 0
Wcount = 0


for i in range(len(S)):
    if S[i] == "W":
        count += i - Wcount
        Wcount += 1

print(count)

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

last = sum(range(cnt))
print(ind-last)

Solution (Python):
s = input()

cnt_white = 0
cnt_move = 0
for i in range(len(s)):    
    if s[i] == 'W':
        cnt_move += i - cnt_white
        cnt_white += 1
print(cnt_move)

Solution (Python):
def main():
    cnt = 0
    num_w = 0
    A = list(input())
    for i in range(len(A)):
        if A[i] == "W":
            cnt += i - num_w
            num_w += 1
    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
s = input()

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

a = 0
for i in range(s.count("W")):
  a += i

print(ans - a)

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

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

cntW = 0
res = 0
for i, s in enumerate(S):
    if s == "W":
        res += i - cntW
        cntW += 1

print(res)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())

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

print(ans)

Solution (Python):
S = input()

tmp = 0
ans = 0

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

Solution (Python):
s = input()
cnt = 0
b_cnt = 0
for c in s:
    if c == 'B':
        b_cnt += 1
    else:
        cnt += b_cnt
print(cnt)

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

Solution (Python):
import sys


def main():
    s = sys.stdin.readline().rstrip()

    black = 0
    ans = 0

    for i in s:
        if i == "B":
            black = black + 1
        else:
            ans = ans + black

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys


def main():
    s = sys.stdin.readline().rstrip()

    black = 0
    ans = 0

    for i in s:
        if i == "B":
            black = black + 1
        else:
            ans = ans + black

    print(ans)

    return


if __name__ == "__main__":
    main()

Solution (Python):
import sys

s = [x for x in sys.stdin.readline().rstrip()]

black = float("inf")
ans = 0

for i in range(len(s)):
    if s[i] == "B" and black > i:
        black = i
    elif s[i] == "W" and black != float("inf"):
        ans += i - black
        black += 1

print(ans)

Solution (Python):
s = input()
n = len(s)
l = [0 for i in range(n)]
cou = 0
for i in range(n):
  k = s[i]
  if k=="B":
    l[i] += 1+l[i-1]
  else:
    l[i] += l[i-1]
    cou += l[i]

print(cou)

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy






INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    s = list(input())

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


if __name__ == '__main__':
    main()

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

print(ans)

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

count = 0

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

choma = 0

for i in range (0, len(S)):
	if S[i] == 'W':
		choma+=(i+1)

if count*(count+1)/2 < choma:
	print(int(choma-count*(count+1)/2))
else:
	print(0)

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

Solution (Python):

def main():
	S = input()
	n = len(S)
	ans = 0

	black = 0
	f_pos = 0
	l_pos = 0

	for i, c in enumerate(S):
		if(c == 'B'):			
			f_pos += i
			black += 1

	l_pos = sum(list(range(n-1, n-1-black, -1)))
	

	ans = l_pos - f_pos

		
	print(ans)

if __name__ == "__main__":
	main()

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
n = len(s)

lastw = 0
ans = 0
for i in range(n - 1, -1, -1):
    if s[i] == 'W':
        lastw = max(lastw, i)
    else:
        ans += max(0, lastw - i)
        lastw = max(0, lastw - 1)

print(ans)

Solution (Python):
def resolve():
  S = input().strip()
  
  ans = 0
  n_black = 0
  for index, s in enumerate(S):
    if s == "B":
      ans += len(S) - index - 1 - n_black
      n_black += 1
  
  print(ans)
resolve()

Solution (Python):
s = input()
ans = 0
b = 0
for c in s:
    if c == 'W':
        ans += b
    elif c == 'B':
        b += 1
print(ans)

Solution (Python):
s = input()



wp=s.count('W')

now=0
count=0
for i in range(len(s)):
    if s[i]=='W':
        now+=i
for i in range(wp):
    count+=i
print(now-count)

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

Solution (Python):
import sys

readline = sys.stdin.readline

def main():
    S = list(readline()[:-1])
    cnt = 0
    ans = 0
    for i, s in enumerate(S):
        if s == 'W':
            ans += i - cnt
            cnt += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
S = input()
b = "B"
w = "W"
con = 0
ans = 0
for i in range(len(S)):
  if S[i] == b:
    con += 1
  elif S[i] == w:
    ans += con
print(ans)

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    res = 0
    num = 0
    for i in range(len(S)):
        if S[i] == 'W':
            res += num
        else:
            num += 1
    print(res)
if __name__ == '__main__':
  main()

Solution (Python):
s = list(input())
len_s = len(s)
len_b = s.count('B')

b_index_list = []

for i in range(len_s):
    if s[i] == 'B':
        b_index_list.append(i)

b_index_list.reverse()
l0 = len_s - 1
cnt = 0

for b in b_index_list:
    cnt += l0 - b
    l0 -= 1

print(cnt)

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

cnt =  0
cnt_W = 0
for i in range(n):
	if s[i] == 'W':
		cnt += i
		cnt_W += 1

res = cnt - (cnt_W - 1) * cnt_W // 2
print(res)

Solution (Python):
s = input()

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

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

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

c = 0
for i in range(n-b_count, n):
    c += i

print(c-b)

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

cnt = 0
ans = 0

for i in s:
    if i == "B":
        cnt += 1
    else:
        ans += cnt
print(ans)

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

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

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

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

print(ans)

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

for s in S:
    if s == 'B':
        b += 1
    else:
        ans += b

print(ans)

Solution (Python):

"""
問題：
一直線上にオセロがある
一回の操作で[黒白]を裏返す時[白黒]、最大何回の操作が行えるか
解法：
まずいちばん最初のBが出てくるところまでは無視できる
そこから、Wが出てくる度にそこまでに出現したBの数を足した合計が答え
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
s = readline().rstrip().decode('utf-8')
flag = 0
black = 0
white = 0
ans = 0
for i in s:
    if flag:
        if i == "B":
            black += 1
        else:
            ans += black
    else:
        if i == "B":
            flag = 1
            black += 1
print(ans)

Solution (Python):

"""
問題：
一直線上にオセロがある
一回の操作で[黒白]を裏返す時[白黒]、最大何回の操作が行えるか
解法：
まずいちばん最初のBが出てくるところまでは無視できる
そこから、Bの数*Wの数が答え
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
s = readline().rstrip().decode('utf-8')
flag = 0
black = 0
white = 0
ans = 0
for i in s:
    if flag:
        if i == "B":
            black += 1
        else:
            ans += black
    else:
        if i == "B":
            flag = 1
            black += 1
print(ans)

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

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

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

Solution (Python):

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

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

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

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

Solution (Python):
def main():
    N = str(input())
    B_count = 0
    result = 0
    for i in range(0, len(N)):
        target = N[i]
        if target == 'W':
            result = result + B_count
        else:
            B_count = B_count + 1        
    print(result)

if __name__ == "__main__":
    main()

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    s = IS()
    s_b = [1 if si == 'B' else 0 for si in s]
    cnt = 0
    ans = 0
    for b in s_b:
        if b == 1:
            cnt += 1
        else:
            ans += cnt
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
s =list(str(input()))
s_replace = [1 if i == "B" else 0 for i in s]

count = 0
ans = 0

for i in range(len(s_replace)):
  if s_replace[i] == 1: 
    count += 1
    continue
  else: 
    ans = ans + count
    continue
    
print(ans)

Solution (Python):




s = input()

sidx = len(s) - 1
bidx = -1
ans = 0
leftflg = True
while(sidx >= 0):
    
    if leftflg and s[sidx] == 'W':
        leftflg = False
        bidx = sidx
    
    elif s[sidx] == 'B':
        ans = ans + max(0, bidx - sidx) 
        bidx = bidx - 1
        
    sidx = sidx - 1


print(ans)

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

ans = 0
cou = 0
for i in range(n):
    if s[i] == "W":
        ans += i - cou
        cou += 1
print(ans)

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

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

Solution (Python):
s = str(input())
n = len(s)
distance = 0
count = 0
max_W = 0

for i in range(n):
    if s[i] == 'W':
        distance += (i - count)
        count += 1
        max_W = i

if s.count('W') == 0 or s.count('W') == n:
    print(0)
    exit()

print(distance)

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

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

Solution (Python):
S = input()

sumB = 0
count = 0
for x in S:
    if x == "B":
        count += 1
    if x == "W":
        sumB += count
print(sumB)

Solution (Python):
S=input()

B=[]
b=0
for i in range(len(S)):
    if S[i]=="B":
        b+=1
        B.append(b)
    else:
        B.append(b)

ans=0
for i in range(len(S)):
    if S[i]=="W":
        ans+=B[i]

print(ans)

Solution (Python):
s=input()
c=0
f=0
ans=0
for i in range(len(s)):
  if f==0 and s[i]=='W':
    c+=1
  elif f==0 and s[i]=='B':
    f=1
  elif f==1 and s[i]=='W':
    ans+=i-c
    c+=1
print(ans)

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

Solution (Python):
s = input() 

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

print(ans)

Solution (Python):
S = str(input())
counter = 0
ans = 0
for i, v in enumerate(S):
    if v == 'B':
        counter += 1
    else:
        ans += counter

print(ans)

Solution (Python):
S=input()
Bind=[]
for i in range(len(S)):
    if S[i]=='B':
        Bind.append(i)
cnt=0
for i in reversed(range(len(Bind))):
    cnt+=len(S)-1-i-Bind[i]
print(cnt)

Solution (Python):
s = list(input())[::-1]

x = 0
ans = 0
for i in range(len(s)):
    if s[i] == "B":
        ans += i-x
        x += 1

print(ans)

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

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

Solution (Python):
S = list(input())
s =len(S)
p = 0
q = 0
for i in range (s):
    if S[i]=='W':
        q += (i - p)
        p += 1
print(q)

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

Solution (Python):
s = input()

w = 0
for c in s:
    if c == 'W':
        w += 1
ans = []

for c in s:
    if c == 'B':
        ans.append(w)
    else:
        w -= 1
print(sum(ans))

Solution (Python):
S = list(input())
black_ind = [i for i, s in enumerate(S) if s == 'B']
current_ind_sum = sum(black_ind)
import numpy as np
final_list = np.arange(len(S))[len(S)-len(black_ind):]
print(sum(final_list)-current_ind_sum)

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