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


def main():
    S = list(input())
    b = 0
    ans = 0
    for s in S:
        if s == 'B':
            b += 1
        else:
            ans += b

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):

def resolve():
    S = input()
    sub = "BW"
    cnt = 0
    sum = 0

    
    st = 0
    end = 0
    for i, s in enumerate(S):
        if s == "B":
            break
        else:
            st += 1

    for i, s in enumerate(S[::-1]):
        
        if s == "W":
            break
        else:
            end += 1

    
    S = S[st:len(S)-end]
    

    foundB = False
    for i, s in enumerate(S):
        if s == "B":
            cnt += 1
            foundB = True
        elif s == "W":
            sum += cnt
            foundB = False
        
        

    print(sum)


if __name__ == "__main__":
    resolve()

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

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

Solution (Python):
S = input()
N = len(S)
cnt = 0
ans = 0
for c in S[::-1]:
  if c == 'W':
    cnt += 1
  else:
    ans += cnt

print(ans)

Solution (Python):
s = list(str(input()))
bCnt = 0
ans = 0

for i in s:
    if i == 'B':
        bCnt += 1
    else:
        ans += bCnt

print(ans)

Solution (Python):
S = list(str(input()))
k = 0
t = -1
N = len(S)
for i in range(N):
  if S[i] == 'B':
    k += N - i - 1
    t += 1
ans = k -  t*(t+1)/2
print(int(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):
def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():
    s = input()

    b_count = s.count('B')

    b_to_end_sum = 0
    for i in range(len(s)):
        target = s[i]
        if target == 'B':
            b_to_end_sum += (len(s) - i - 1)

    result = b_to_end_sum - sum([i for i in range(b_count)])
    print(result)

run()

Solution (Python):
S = input()

cnt = 0
b = 0
for i,s in enumerate(S):
  if s == "W":
    cnt+=b
  else:
    b+=1
print(cnt)

Solution (Python):


def main():
    s = input()
    n = len(s)
    cn = 0
    ans = 0
    for i in range(n):
        if s[i] == 'W':
            ans += (i - cn)
            cn += 1
    print(ans)



if __name__ == '__main__':
    main()

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

num_b = 0
ans = 0
for v in S:
    if v == 'B':
        num_b += 1
    else:
        ans += num_b

print(ans)

Solution (Python):
S = input()

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

Solution (Python):
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

s = S()
















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

Solution (Python):
s = input()

ind = []
for i in range(len(s)):
    if s[i] == "B":
        ind.append(i)

cnt = s.count("B")

target = list(range(len(s)))[-cnt:]

ans = 0
for t, i in zip(target, ind):
    ans += t-i
print(ans)

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

Solution (Python):
from collections import Counter

S = input()
s_list = []
for i, s in enumerate(S):
  if s == 'W':
    s_list.append(i)
t_list = [i for i in range(len(s_list))]
answer = 0
for i in range(len(s_list)):
  answer += s_list[i] - t_list[i]
print(answer)

Solution (Python):
def main():
    s = input()
    count = 0
    b_count = []
    for v in s:
        if v == "B":
            count += 1
        if v == "W":
            b_count.append(count)
    print(sum(b_count))

def input_list():
    return map(int, input().split())

if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = list(reversed(input().strip()))
black = 0
ans = 0

for i, v in enumerate(s):
    if v == 'W':
        continue
    else:
        ans += (i - black)
        black += 1
print(ans)

Solution (Python):



S = list(input())
next_w = 0
ans = 0

for i in range(len(S)):
    if S[i] == 'W':
        back = i - next_w
        ans += back
        next_w = i - back + 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()

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

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

Wcnt = 0
res = 0

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

print(res)

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

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

Solution (Python):
import sys
input = sys.stdin.readline

S=list(input().strip())
S.reverse()

sum = 0
n = 0
for i in range(len(S)):
    if S[i] == 'B':
        sum += (i-n)
        n += 1
print(sum)

Solution (Python):

S = list(input())

cnt_b = 0 
ans = 0

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

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

ans = 0

cntB = 0

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

print(ans)

Solution (Python):
def main():
    s = input()
    count = 0
    black_count = 0
    for i in range(len(s)):
        if s[i] == 'B':
            black_count += 1
        if s[i] == 'W':
            count += black_count

    print(count)


if __name__ == "__main__":
    main()

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()
ans,cnt=0,0
for i in range(len(s)):
  if s[i]=="B":
    cnt+=1
  else:
    ans+=cnt
print(ans)

Solution (Python):
S = list(input())
cntb = 0
cntw = 0
for i in range(len(S)):
    if S[i] == "B":
        cntb +=1
    if S[i] == "W":
        cntw += cntb
print(cntw)

Solution (Python):
import sys
a = [ c for c in input()]
B = 0
W = 0
for i in range(len(a)):
    if a[i] == "B":
        B += 1
    else:
        W += B

print(W)

Solution (Python):
str = input()

n = len(str)
p = 0
ans = 0
for i in range(n):
    if str[i] == 'W':
        ans += i - p
        p += 1

print (ans)

Solution (Python):

S = input()
cnt = 0
B_cnt = 0
ans = 0
for s in reversed(S):
    
    if s == "B":
        ans += (cnt - B_cnt)
        B_cnt += 1
    cnt += 1
    
    
print(ans)

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

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

pre, pst=0,0
for i in range(num):
    if s[i]=='B': pre+=i

s=sorted(s,reverse=1)
for i in range(num):
    if s[i]=='B': pst+=i

print(pst - pre)

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

s = v()
w_a = [1 if i=="W" else 0 for i in s]
w_cnt = list(itertools.accumulate(w_a))

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

print(ans)

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

Solution (Python):
import sys
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(10**6)
INF = 10**20

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])

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

Solution (Python):
S=input()

start=0
for i in range(len(S)):
    start=i
    if S[i]=='B':
        break

left_W=start
ans=0
if start<len(S)-1:
    for i in range(start+1,len(S)):
        if S[i]=='W':
            ans+=i-left_W
            left_W+=1

print(ans)

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

Solution (Python):
s = input()

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

print(ans)

Solution (Python):
s = input()
black = 0
ans = 0

for i in range(len(s)):
    if s[i] == 'W':
        ans += black
    else:
        black += 1

print(ans)

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

Solution (Python):
s=input()

ans=0
cnt=0
for i,j in enumerate(s):
  if j=="W":
    ans+=i-cnt
    cnt+=1
    
print(ans)

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

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

_sum = 0
ans = 0

for s in S:
  
  if s == "B":
    _sum += 1
    
  elif s == "W":
    ans += _sum
    
print(ans)

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

W = []
for i in range(N):
  if S[i] == "W":
    W.append(i)

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

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

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

Solution (Python):
S = input()

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

B_count = S.count("B")
destination_B_index_sum = (len(S)*B_count) - sum(range(B_count))

print(max(0, destination_B_index_sum - B_index_sum))

Solution (Python):
S = input()

p = 0
ans = 0

for i, c in enumerate(S):
  if c == 'B':
    continue
  ans += (i - p)
  p += 1
  
print(ans)

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

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

num = s.count('W')

before = 0
for i in range(len(s)):

    if s[i]=='W':
        before += i


after = 0
for j in range(num):
    after+=j

print(before-after)

Solution (Python):
S = input()

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

print(ans)

Solution (Python):
S = input()

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

Solution (Python):


S = input()

ret  = 0
numW = 0
for c in reversed(S):
    if c == 'B':
        ret += numW
    else:
        numW+=1

print(ret)

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

print(ans)

Solution (Python):
a = input()
b = int(len(a))
c = int(0)
d = int(0)
e = int(0)
for i in range(b):
  if a[i] == "W":
    c += 1

for i in range(b):
  if a[i] == "W":
    e = e + int(i) - d
    d += 1

print(e)

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

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

cnt = [0]*len(S)

cnt_B = 0
for i,j in enumerate(S):
    if j == 'B':
        cnt_B += 1
    if j == 'W':
        cnt[i] = cnt_B
print(sum(cnt))

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

WWW = S.count("W")

for i in range(N):
    if S[i] == "B":
        ans += WWW
    if S[i] == "W":
        WWW -= 1

print(ans)

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

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

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

cur_b = 0

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

print(ans)

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

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


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

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


S = S()
num_w = S.count('W')
num_b = len(S) - num_w
left_w_pos = 0
ans = 0
for i, s in enumerate(S):
    if (s == 'W'):
        ans += (i-left_w_pos)
        left_w_pos += 1
print(ans)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    s = S()
    alldic = collections.Counter(s)
    wnum = alldic["W"]
    leftdic = collections.Counter(s[:wnum])
    leftbnum = leftdic["B"]
    right_w_in = wnum-1
    left_b_in = right_w_in + 1
    ans = leftbnum

    for i,x in enumerate(s):
        if i<=right_w_in:
            if x == "B":
                ans += right_w_in - i
        elif i>=left_b_in:
            if x == "W":
                ans += i - left_b_in
    
    print(ans)
main()

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

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

Solution (Python):
S = input()

w_list = [0]
ans=0
for i in range(len(S)):
    if S[i]=='W':
        w_list.append(i+1)

for i in range(1,len(w_list)):
    ans += w_list[i]-i
    
print(ans)

Solution (Python):
othello = input()
bef = 0
sumall = 0
count = 0

for i in range(len(othello)):
    sumall += i
    if(othello[i] == 'B'):
        bef += i
        count += 1

sumelse = 0
for i in range(len(othello)-count):
    sumelse += i

aft = sumall - sumelse

print(aft - bef)

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

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

for s in S:
    if s=='B':
        cnt+=1
    else:
        ans+=cnt
print(ans)

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

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

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

Solution (Python):
S = input()

count=S.count("W")
a=0
mylist=[]

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

for j in range(len(mylist)):
    a=a+mylist[j]-j-1
print(a)

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 = list(input())
count = 0
valueA = 0
for i in range(len(S)):
  if S[i] == 'B':
    count += 1
    valueA += i

valueB = 0
for i in range(count):
  valueB += (len(S) - 1 - i)
  
print(valueB - valueA)

Solution (Python):
S = input()
n = S.count('W')
print(sum([i for i in range(len(S)) if S[i]=='W']) - n*(n-1)//2)

Solution (Python):
s = input()
len_s = len(s)
cnt_b = s.count('B')
diff_list = [i for i in range(len_s - cnt_b, len_s)][::-1]
b_idx = []

for idx, el in enumerate(s):
    if el == 'B':
        b_idx.append(idx)
    else:
        pass

total = 0
for pos, idx in zip(diff_list, b_idx):
    total += pos - idx
print(total)

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)

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()
count = 0
ans = 0
for i in s:
    if i == "W":
        ans += count
    else:
        count += 1
print(ans)

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

Solution (Python):
S=[x for x in input()]
ans=0
W_cnt=S.count('W')

for s in S:
  if s=='W':
    W_cnt-=1
  elif s=='B':
    ans+=W_cnt
print(ans)

Solution (Python):
S = input()
res = 0
w_ind = 0
for i, s in enumerate(S):
    if s == "B":
        pass
    elif s == "W":
        res += i - w_ind
        w_ind += 1
print(res)

Solution (Python):
s = list(input())
l = []
for i in range(len(s)):
    if s[i] == "W":
        l.append(i)
print(sum(l) - s.count("W")*(s.count("W")-1)//2)

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

print(ans)

Solution (Python):
S = input().strip()
l=len(S)
motomoto=0
b=S.count('B')
saisyuu=((2*l-b-1)*b)//2
for i in range(l):
    if S[i]=='B':
        motomoto+=i
print(saisyuu-motomoto)

Solution (Python):
import math

S = list(input())

t = 0

res = 0

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

if len(S) == 1:
    print(0)

elif S.count("B") == 1 and S[-1] == "B":
    print(0)

else:
    print(res)

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

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

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

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)

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

ans = 0
black = 0

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

print(ans)

Solution (Python):
S = input()
W = []
 
for i, s in enumerate(S):
  if s == 'W':
    W.append(i)

idx = 0
ans = 0
for w in W:
  ans += w-idx
  idx += 1

print(ans)

Solution (Python):
def resolve():
    s = str(input())
    ans = 0
    ind = []
    for i, char in enumerate(s):
        if char == 'W':
            ind.append(i)
    lst = 0
    
    for i in ind:
        ans += (i - lst)
        lst += 1

    
    print(ans)
    return


resolve()

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

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

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

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

Solution (Python):
s = input()

b = 0
c = 0
for i in range(len(s)):
    if s[i] == "B":
        b += 1
    else:
        c += b

print(c)

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

print(counter)

Solution (Python):
S = input()
w_position_list = []
for i, s in enumerate(S):
    if s == 'W':
        w_position_list.append(i)
n_w = len(w_position_list)
res = sum(w_position_list) - (n_w *(n_w-1)/2)
print(int(res))

Solution (Python):
def solve():
    S = input()
    ans = 0
    B_cnt = 0
    for s in S:
        if s == 'W':
            ans += B_cnt
        else:
            B_cnt += 1
    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1]

  cnt = 0
  nw = 0
  for i, s in enumerate(S):
    if s == 'W':
      cnt += (i-nw)
      nw += 1

  print(cnt)


if(__name__ == '__main__'):
  main()

Solution (Python):
import sys

s = input()
first = s.find('B')

if first == -1:
    print(0)
    sys.exit()

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

print(ans)

Solution (Python):
S = input()
n = len(S)
l = [0 if S[i] == 'B' else 1 for i in range(n)]
cnt = 0
lenB = 1
for i in range(n-1):
    if l[i] == 0 and l[i+1] == 0: lenB += 1
    if l[i] == 0 and l[i+1] == 1:
        l[i+1] = 0
        cnt += lenB
print(cnt)

Solution (Python):
S=input()
N=len(S)
answer=0
saidai=N-1
for n in range(N):
    if S[n]=='B':
        answer+=saidai-n
        saidai-=1

print(answer)

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

ans, cntB = 0, 0
for i in range(n):
    if s[i] == 'B':
        cntB += 1
    else:
        ans += cntB

print(ans)

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

Solution (Python):
s=list(input())
cnt=s.count('W')
a=[i for i,x in enumerate(s) if x=='W']
ans=0
for i in range(cnt):
  ans+=a[i]-i
print(ans)

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

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

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

Solution (Python):
import numpy
from numpy.core.defchararray import count
S = numpy.array([0 if s == 'B' else 1 for s in input()])

count = 0
bcount = 0

for i, s in enumerate(S):
    if s == 0:
        bcount += 1
    else:
        count += bcount

print(count)

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

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

print(count)

Solution (Python):
s = input()

w = 0
ans = 0

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

print(ans)

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

Solution (Python):
S = input()
lenS = len(S)
bcnt = S.count('B')
wcnt = lenS - bcnt
if bcnt > wcnt:
    ms = 'W'
    rc = wcnt
else:
    ms = 'B'
    rc = bcnt
sum = 0

for i, s in enumerate(S):
    if rc == 0:
        break
    if s == ms:
        if ms == 'W':
            sum += i-rc+1
        elif ms == 'B':
            sum += lenS-i-rc
        rc -= 1
print(sum)

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

Solution (Python):
s=input()

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

print(ans)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    ans = 0
    b = 0

    for char in s:
        if char == "B":
            b += 1
        else:
            ans += b

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()

if __name__=='__main__':
    sl = list(S())
    ans = 0
    c = 0
    for i,item in enumerate(sl):
        if item=='W':
            ans += c
        else:
            c += 1

    print(ans)
    exit()

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

Solution (Python):
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    s = list(readline().rstrip())
    sumS = 0
    m = s.count('B')
    for i in range(len(s) - 1):
        if s[i] == 'B':
            sumS += (len(s) - m) - i
            m -= 1
    print(sumS)


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
size = len(s)
b_num = 0
w_num = 0

for each in s:
    if each == 'W':
        w_num += 1
    else:
        b_num += 1

ans = 0
b_left = w_num
for i in range(size):
    if s[i] == 'B':
       ans += b_left - i
       b_left += 1

print(ans)

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

print(p)

Solution (Python):




S = input()

ans = 0

a = 0

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

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

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

Solution (Python):
S = input()

b_count = 0
ans = 0

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

print(ans)

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

ans = 0;
for i, s in enumerate(S):
    if s == "B":
        ans += len(S) - i
        
for i in range(1,S.count("B")+1):
    ans -= i
print(ans)

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

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

num = []
cnt = 0

for i in range(len(s)):
    if s[i] =="W":
        cnt +=1
    else:
        num.append(cnt)
print(sum(num))

Solution (Python):
s = input()

ans, b = 0, 0
for i in s:
    if i == "B":
        b += 1
    else:
        ans += b

print(ans)