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()
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()
W = S.count("W")
ans = 0
for i in range(len(S)):
    if S[i] == "W":
        ans += i
ans -= W*(W-1)//2
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans = 0
    S = input().rstrip('\n')
    w = 0
    for s in S[::-1]:
        if s == 'W':
            w += 1
        else:
            ans += w
    print(ans)

if __name__ == '__main__':
    main()

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

w_count = 0
move = 0
for i in range(len(S)-1,-1,-1):
    if S[i] == "B":
        move += w_count
    else:
        w_count += 1

print(move)

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

Solution (Python):

s=input()
c=0
a=0
for i in s:
    if i =="W":
        a += c
    else:
        c += 1
print(a)

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

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

Solution (Python):
S = input()

b_count = 0
result = 0
for i in S:
    if i == 'B':
        b_count += 1
        w_count = 0
    else:
        if b_count != 0:
            result += b_count

print(result)

Solution (Python):
s = input()
n = len(s)
b_num = 0
prev_score = 0

for i in range(n):
    if s[i] == "B":
        prev_score += i
        b_num += 1

nxt_score = n * (n - 1) // 2 - (n - b_num) * (n - 1 - b_num) // 2
print(nxt_score - prev_score)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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

Solution (Python):
def main():
    s=input()
    l=0
    man=0
    for i,v in enumerate(s):
        if v == "W":
            man += i-l
            l += 1
    print(man)
    
if __name__ == "__main__":
    main()

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

print(ans)

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

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

Solution (Python):
s = list(input())
ls = len(s)
ss = sorted(s, reverse=True)
cnt = [0, 0]
ans = 0
w = 0

while ss[w] == "W":
    w += 1
    if ls == w:
        break

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

print(ans//2)

Solution (Python):
S=input()
X=K=0
for i in range(1,len(S)+1):
    if S[i-1]=="W":
        X+=i
        K+=1
print(X-(K*(K+1))//2)

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()

    ret, cnt = 0, 0
    for s in S:
        if s == 'B':
            cnt += 1
        if s == 'W':
            ret += cnt
    print(ret)


if __name__ == '__main__':
    main()

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

cnt = 0
b = -1

for idx in range(len(s)):
    if s[idx] is 'W':
        continue
    b += 1
    cnt = cnt + idx - b

print(cnt)

Solution (Python):


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

Solution (Python):
S = input()

count = 0
black = 0
white = 0

for i in range(len(S)-1):
    if S[i] == 'B':
        black +=1
    else :
        white +=1
    if  S[i+1] == 'W':
        count += i+1 -white

print(count)

Solution (Python):
import sys
input=sys.stdin.readline
s=input().rstrip()
idousaki=0
ans=0
for i in range(len(s)):
    if s[i]=="W":
        ans+=(i-idousaki)
        idousaki+=1

print(ans)

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

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

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

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

Solution (Python):
S = input()

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

Solution (Python):
S = list(map(str, input()))
ans = 0
L = []
for x, s in enumerate(S):
  if s == "B":
    L.append(x)
num = len(S) - len(L)
for l in L:
  ans += num - l
  num += 1
print(ans)

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

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

print(ans)

Solution (Python):

def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()

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

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

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

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S = input()
    l = []
    for i in range(len(S)):
        if S[i] == 'W':
            l.append(i-len(l))
    print(sum(l))


if __name__ == '__main__':
    main()

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
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 S(): return input()
def LS(): return input().split()


INF = float('inf')


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

print(ans)

Solution (Python):
s=input()
check=list(s)
n=len(s)
cntb=0
for i in check:
    if i=='B':
        cntb+=1
minus=sum([i+1 for i in range(n) if check[i]=='B' ])
plus=sum(range(n-cntb+1,n+1))
print(plus-minus)

Solution (Python):
S = input()


idx_w = 0
idxes_b = []

for i, s in enumerate(S):
    if s == 'B':
        idxes_b.append(i)
    elif s == 'W':
        idx_w = i

idxes_b = [b for b in idxes_b if idx_w > b]

ans = 0
for i, b in enumerate(idxes_b[::-1]):
    ans += idx_w - b - i

print(max(0, ans))

Solution (Python):
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
w = s.count('W')

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

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

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

Solution (Python):
s = input()

left = 0
ans = 0

for x in s:
    if x == 'B':
        left += 1
        continue
    ans += left

print(ans)

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

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

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

Solution (Python):




import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy












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 = reversed(input())

ans = 0
cnt = 0
for x in s:
    if x=='W':
        cnt += 1
    else:
        ans += cnt

print(ans)

Solution (Python):
s = input()
l = [char for char in s]
ans = 0
c = 0
for val in range(len(l)):
    if l[val] == "W":
        ans += (val - c)
        c+=1
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):
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

s = input()

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

Solution (Python):
S = input()
ans = 0
wc = 0
for i in reversed(S):
    if i == "W":
        wc += 1
    else:
        ans += wc
print(ans)

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

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

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

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

Solution (Python):
S = input()

tmp = 0
rlt = 0

for s in S:
  if s == "B":
    tmp += 1
  else:
    rlt += tmp
    
print(rlt)

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

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

print(ans)

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

Solution (Python):
s = input()

import numpy as np
B = []
W = []
for i in range(len(s)):
    if s[i] == "B":
        B.append(i)
    elif s[i] == "W":
        W.append(i)

print(sum(np.array(W) - np.array([i for i in range(len(W))])))

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

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()
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()
n=len(s)
ret=0
pos=0
for i in range(n):
    if s[i]=="W":
        ret+=i-pos
        pos+=1
print(ret)

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

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

ans -= (cnt*(cnt-1))//2
print(ans)

Solution (Python):
r = input()

s = 0
c = 0

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

print(s)

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

l = list(S)



ans = 0


b=0

for i in range(len(l)):
  if l[i] == "W": 
    ans += b
  else: 
    b += 1

print(ans)

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

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

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

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

Solution (Python):







S = [0] + list(input())


N = len(S) - 1


i = 1
while 1:
    

    if i == N:
        print(0)
        break
    elif S[i] == "W":
        i += 1
    else:
        

        ans = 0
        start = i
        B_count = 1

        for j in range(start+1,N+1):
            if S[j] == "W":
                ans += B_count
            elif S[j] == "B":
                B_count += 1
        print(ans)
        break

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, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


S = input()

flg = False
cnt = 0
ans = 0

for i in range(len(S)):
	if flg == False and S[i] == "B":
		flg = True
		start = i

	if flg and S[i] == "W":
		ans += i - start - cnt
		cnt += 1

print(ans)

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    ans = 0
    count = 0
    for i in range(len(s)):
        if s[i] == 'W':
            ans += i - count
            count += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
S = input()

b_cumsum = [0] * len(S)
now = 0
for i in range(len(S)):
    if S[i] == "B":
        b_cumsum[i] = now + 1
        now += 1
    else:
        b_cumsum[i] = now

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

print(ans)

Solution (Python):
from collections import Counter, defaultdict, deque
s = input()



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

Solution (Python):
s=input()
bl=[]
wl=[]
for j,si in enumerate(s):
  if si=="B":
    bl.append(j)
  else:
    wl.append(j)

blen=len(bl)
wlen=len(wl)

ans=0
for i,j in zip(wl,range(wlen)):
  ans+=abs(i-j)
  
print(ans)

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
n=len(s)
l=[0]*n
c=0
for i in range(n):
    if s[-1-i]=="W":
        c+=1
    l[-1-i]=c
ans=0
for i in range(n):
    if s[i]=="B":
        ans+=l[i]
print(ans)

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

Solution (Python):
S=input()
S=S[::-1]
B_index=[i for i, x in enumerate(S) if x == 'B']
for i in range(len(B_index)):
    B_index[i]=B_index[i]-i
print(sum(B_index))

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

Solution (Python):

import sys


def solve(S: str):
    count = 0
    S = [s for s in S]

    count = 0
    sub_count = 0

    for s in S:
        if s == 'W':
            count += sub_count
        else:
            sub_count += 1
                
        
    print(count)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
s = list(input())
n = len(s)
ans = 0
count = 0

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

print(ans-count*(count-1)//2)

Solution (Python):
s=list(input())
co=0
ans=0
for (c,i) in zip(s,range(len(s))):

  if c== "W":
    ans+=i-co
    co+=1
    
print(ans)

Solution (Python):
S = input()

res = 0
bc = 0
for s in S:
    if s == "B":
        bc += 1
    else:
        res += bc

print(res)

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

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

Solution (Python):
x= input()
l_w = []
for i in range(len(x)):
    if x[i] == 'W':
        l_w.append(i)

sum = 0
st = 0
for i,j in enumerate(l_w):
    sum += j-st
    st+= 1
print(sum)

Solution (Python):






S = list(input())





w_count = S.count("W")
print(sum([idx for idx,x in enumerate(S) if x == "W"]) - (w_count-1)*w_count//2)

Solution (Python):
st = list(map(lambda x: x=='B',input()))[::-1]

ans = 0

count = 0

for i, v in enumerate(st):
    if v:
        ans += i - count
        count += 1

print(ans)

Solution (Python):












S= str(input())




w = S.count('W')
b = S.count('B')
c=0
v=0
for i in range(len(S)):
    if S[i]=='B':
        v+=1
        c += (len(S)-b + v) - (i +1)
print(c)

Solution (Python):
S = input()

b_cnt = 0
C = [0] * len(S)
for i in range(len(S)):
    if S[i] == 'B':
        
        b_cnt += 1
    if S[i] == 'W':
        
        C[i] = b_cnt

print(sum(C))

Solution (Python):



def main():
    S = input()

    ret = 0
    cntW = 0
    cntB = 0
    for i, si in enumerate(S):
        
        if si=='W':
            cntW+=1
            ret+=cntB
        else:
            cntB+=1

    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):


import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = readline().decode().rstrip()

res = 0
b_cnt = 0

for c in S:
    if c == 'B':
        b_cnt += 1
    elif c == 'W':
        res += b_cnt

print(res)

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    S = input()
    count_B = 0
    ans = 0
    for c in S:
        if c == 'B':
            count_B += 1
        else:
            ans += count_B
    print(ans)
    
main()

Solution (Python):
s = input()

a = 0
b = s.count('B')
move = 0

for i in reversed(range(len(s))):
    if s[i] == 'B':
        move += (len(s) - a - (i + 1))
        a += 1
print(move)

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

Solution (Python):

s = input()
ans = 0
tmp = 0

for c in reversed(s):
    if c == 'W':
        tmp += 1
    else:
        ans += tmp
print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  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 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)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




S = S()
N = len(S)
ans = 0
count = 0
for i in range(N):
  if S[i] == "B":
    ans += N-1-i
    count += 1
print(ans-(count-1)*count//2)

Solution (Python):
def main():
    S = input()
    ans = 0
    wc = 0

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
sl = []
for i in range(len(S)):
    sl.append(S[i])
count = 0
memo = 0
for i in range(len(S)-1):
    if sl[i] == "B" and sl[i+1] == "W":
        count += 1+memo
        sl[i+1] = "B"
    elif sl[i] == "B" and sl[i+1] == "B":
        memo += 1

print(count)

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

Solution (Python):
S = input()

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

print(ans)

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

Solution (Python):
S = input()
a = []
w_lt = 0
flag = True
for i in range(len(S)):
    if S[i] == "W":
        a.append(i)
    else:
        flag = False
if not flag:
    suma = 0
    for i in range(len(a)):
        suma += a[i] - i
    print(suma)
else:
    print("0")

Solution (Python):
S = list(input())
n = len(S)
cnt_b = 0
cnt = 0
for i in range(n):
    if S[i] == 'B':
        cnt_b += 1
        cnt += i
ans = int((2*n - cnt_b -1)*cnt_b*0.5 - cnt)
print(ans)

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

def linput():
	return list(map(float,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	S = input().rstrip()
	
	res = 0
	B = 0
	
	for s in S:
		if s=='B': B+=1
		else: res += B
	print(res)

if __name__ == "__main__":
	main()

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

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

Solution (Python):

import math


def inp():
    return(int(input()))



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



def instr():
    s = input()
    return(list(s[:len(s)]))



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


s = input()
n = len(s)
end = n-1
movement = 0
for i in range(n-1, -1, -1):
    if s[i] == 'B':
        movement += end - i
        end -= 1
print(movement)

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 = input()
ans = 0
cnt = 0
for s in S[::-1]:
  if s == 'W':
    cnt += 1
  else:
    ans += cnt

print(ans)

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

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

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

if wcnt==len(s):
    print(0)
else:
    print(cnt)

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

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    ans = 0
    n_black = 0
    for s in S:
        if s == "B":
            n_black += 1
        else:
            ans += n_black

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    ans = 0
    n_white = 0
    for s in S[::-1]:
        if s == "W":
            n_white += 1
        else:
            ans += n_white

    print(ans)


if __name__ == "__main__":
    main()

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


w_sum = 0
w_n = 0
for i, c in enumerate(s):
    if c == "W":
        w_sum += i
        w_n += 1
    
print(w_sum - w_n*(w_n-1)//2)

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