peterverebics/CodeNet_Python_118 huggingface dataset:
def main():
    N = int(input())
    S = input()
    border = S.count("R")
    ans = 0
    for i in range(N):
        if S[i] == "W" and i < border:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
n = int(input())
c = input()
l = 0
r = n-1
ans = 0
while l<r:
    if c[l] == "R": l += 1
    if c[r] == "W": r -= 1
    
    if c[l]=="W" and c[r]=="R":
        l += 1
        r -= 1
        ans += 1
        
print(ans)
n = int(input())
C = input()
sR = [0]*(n+1)
sW = [0]*(n+1)

for i in range(n):
    sR[i+1] = sR[i] + (C[i] == "R")
    sW[i+1] = sW[i] + (C[i] == "W")

ans = 10**10
for i in range(n+1):
    r = sR[n] - sR[i]
    w = sW[i]
    ans = min(ans, max(r,w))
print(ans)
n = input()
data = input()

w = []
r = []
for i in range(len(data)):
  if data[i] == "W":
    w.append(i)
  else:
    r.append(i)

ans = 0
if len(w) == 0:
  print(ans)
elif len(r) == 0:
  print(ans)
else:
  r = r[::-1]
  for i in range(min(len(w), len(r))):
    tmp_w = w[i]
    tmp_r = r[i]
    if tmp_w <= tmp_r:
      r.append(tmp_w)
      w.append(tmp_r)
      ans += 1
    else:
      break
  print(ans)
n = int(input())
c = [i for i in input()]
cnt = 0
for num, i in enumerate(sorted(c)):
    if c[num] != i:
        cnt += 1
print(cnt // 2)
n = int(input())
wr = input()
R_cnt = wr.count('R')
ans = wr.count('W',0,R_cnt)
print(ans)
N = int(input())
c = input()
white = 0
white_ends = 0

for i in range(N):
  if c[i] == "W":
    white += 1
for i in range(N-white, N):
  if c[i] == "W":
    white_ends += 1
print(white-white_ends)
n=int(input())
c=input()
a=c.count('R')
print(a-c[:a].count('R'))
n = int(input())
c_l = list(input())
c_l = [ 1  if c == 'R' else 0 for c in c_l ]
r_n = sum(c_l)
w_n = sum(c_l[:r_n])
print(r_n-w_n)
N = int(input())
c = input()

cR = c.count('R')
cW = c.count('W')


if all([i == 'R' for i in c[:cR]]):
    print(0)
    exit()

if all([i == 'W' for i in c[cR:cR+cW]]):
    print(0)
    exit()

ans = c[:cR].count('W')

print(ans)
n = int(input())
s = input()
w = s.count('W')
print(0 if w == 0 else s[-w:].count('R'))
n = int(input())
c = list(input())

i = 0
j = len(c)-1
cnt = 0

while i < j:
  if c[i] == "R":
    i += 1
    continue
  if c[j] == "W":
    j -= 1
    continue
  i += 1
  j -= 1
  cnt += 1
print(cnt)
N, = map(int, input().split())
X = input().strip()
i,j = 0,N-1
R = 0
while i<=j:
    if X[i] == "R":
        i += 1
        continue
    if X[j] == "W":
        j -= 1
        continue
    R += 1
    i += 1
    j -= 1
print(R)
n = int(input())
moji = input()

num_r = moji.count('R')
num_w = moji.count('W')

ext_moji = moji[:num_r]
print(ext_moji.count("W"))
N = int(input())
C = list(input())

W = C.count("W")
R = C.count("R")
w = 0
r = R

ans = R
for i in range(1,N+1):
  if C[i-1] == "W":
    w += 1
  else:
    r -= 1
  ans = min(ans, max(w,r))
  
print(ans)
n = int(input())
C = list(input())
r = C.count('R')
c = 0
for i in range(r, n):
    if C[i] == 'R': c += 1
print(c)
n = int(input())
c = list(input())
c_sort = sorted(c)

count = 0

for i in range(n):
    if c[i]  != c_sort[i]:
        count += 1
print(count//2)
from collections import Counter

N=int(input())
color=input()

c = Counter(color)
r = c['R']

count = 0
for i in range(N):
  if r == 0:break
  if color[i]=='W':
    count += 1
    r -= 1
  else:
    r -= 1

print(count)
N = int(input())

C = list(input())

res = 0
j = N - 1
for i in range(N):
    if C[i] == "W":
        while i < j:
            if C[j] == "R":
                res += 1
                C[i] = "R"
                C[j] = "W"
                break
            j -= 1
    if i >= j:
        break

print(res)
n = input()
balls = list(input())

backindex = len(balls) - 1
frontindex = 0
actions = 0

while frontindex < backindex:
  if balls[frontindex] == 'W':
    while backindex > frontindex:
      if balls[backindex] == 'R':
        balls[frontindex] = 'R'
        balls[backindex] = 'W'
        actions += 1
        break
      backindex -= 1
  frontindex += 1

print(actions)
n = int(input())
s = input()
ans = 0

while True:
    if not ('R' in s and 'W' in s): break
    r = s.rindex('R')
    w = s.index('W')
    if r < w:
        break
    s = s[:w] + 'R' + s[w+1:r] + 'W' + s[r+1:]
    ans += 1
print(ans)
N = int(input())
cs = list(input())

ans = 0
sorted = N - 1
for i in range(N):
  if cs[i] == "W":
    for j in range(sorted, i, -1):
      sorted = j - 1
      if cs[j] == "R":
        cs[i], cs[j] = cs[j], cs[i]
        ans += 1
        break
  if (i + 1) > sorted:
    break
print(str(ans))
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
n = int(input())
#n, d = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))

rc = 0
for i in range(n):
    if s[i] == "R":
        rc += 1

wc = 0
for i in range(rc):
    if s[i] == "W":
        wc += 1

print(wc)
N = int(input())
cs = [i for i in input()]
n_R = 0
for c in cs:
    if c == 'R':
        n_R += 1
n_n_R = 0
for i in range(n_R):
    if cs[i] == 'R':
        n_n_R += 1
print(n_R - n_n_R)
N = int(input())
C = input()
 
R_cnt = C.count('R')
x = C[:R_cnt].count('R')
 
print(R_cnt-x)
n = int(input())
C = input()
chk = 0
for i in range(n):
    if C[n-1-i] == 'R':
        chk = n-1-i
        break
cnt = 1
for i in range(chk):
    if C[i] == 'R':
        cnt += 1
ans = 0
for i in range(cnt):
    if C[i] == 'W':
        ans += 1
if 'R' not in C:
    print(0)
else:
    print(ans)
n = int(input())
c = input()

r_num = c.count("R")
c_left = c[:r_num]
r_num_left = c_left.count("R")
print(r_num - r_num_left)
n = int(input())
c = input()

r, w = 0, 0
for i in range(n):
    if c[i] == 'R':
        r += 1
    else:
        w += 1

ans = 0
for i in range(r):
    if c[i] == 'W':
        ans += 1

print(ans)
# import sys
# input = sys.stdin.readline

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

n = int(input())
c = list(input())
r = 0
w = 0
for i in range(n):
    if c[i] == "R":
        r += 1
    else:
        w += 1
ans = 0
for i in range(r):
    if c[i] != "R":
        ans += 1
print(ans)
N = int(input())
C = input()
rcount = C.count("R")

ans = 0
w = 0
r = 0
for i in range(rcount):
    if C[i] == "W":
        if r > 0:
            r -= 1
            ans += 1
        else:
            w += 1
    j = N - i - 1
    if C[j] == "R":
        if w > 0:
            w -= 1
            ans += 1
        else:
            r += 1
ans += w
print(ans)
n = int(input())
stones = list(input())
w_num = 0
r_num = 0
for i in stones:
    if i == 'W':
        w_num += 1
    else:
        r_num += 1
goal = 'R' * r_num + 'W' * w_num

index = 0
poplist = list()
for i in stones:
    if i == goal[index]:
        poplist.append(index)
    index += 1
for i in sorted(poplist, reverse=True):
    stones.pop(i)
w_num = 0
r_num = 0
for i in stones:
    if i == 'W':
        w_num += 1
    else:
        r_num += 1
print(min(w_num, r_num))
import sys

n = int(input())

s = input()

count_w = s.count('W')
count_r = n - count_w

if count_w == 0 or count_r == 0:
    print(0)
    sys.exit()

sa = s[:count_r]
sb = s[count_r:]
num_sa = sa.count('W')
num_sb = sb.count('R')
if num_sa <= num_sb:
    print(num_sa)
else:
    print(num_sb)
N=int(input())
S=input()
a=S.count("W")
b=S.count("R")
print(min([S[:b].count("W"),a,b]))
# -*- coding: utf-8 -*-
n = int(input())
cs = input()
r_num = 0
w_num = 0
# RRR|WWWW にする
r_num = cs.count('R')
w_num = cs.count('W')

if r_num == 0 or w_num == 0:
    print(0)
else:
    ans = []
    W = 0
    rl_num = 0
    for c in cs:
        if c == 'R':
            rl_num += 1
        elif c == 'W':
            W += 1
        R = r_num - rl_num
        ans.append(max(W, R))

    print(min(ans))
n=int(input())
S=input()
c=0
for i in range(n):
  if S[i]=="R":
    c=c+1
d=0
for i in range(c):
  if S[i]=="R":
    d=d+1
print(c-d)
n = int(input())
c = ','.join(input()).split(',')

ans = 0

ri = -1

if c.count('W') == 0:
    print(0)
    exit()

if c.count('R') == 0:
    print(0)
    exit()

for i in range(n):
    if c[i] == 'W':
        while c[ri] != 'R':
            ri -= 1
        
        if n < i-ri:
            break
        
        c[i], c[ri] = 'R', 'W'
        ans += 1
    
print(ans)
n = int(input())
s = input()
w = []
r = []
for i,j in enumerate(s):
  if j == 'W':
    w.append(i)
  else:
    r.append(i)
if len(w) == 0 or len(r) == 0:
  print(0)
else:
  p = -1
  q = 0
  ans = 0
  mp = len(r)
  mq = len(w)
  while r[p] > w[q]:
    ans += 1
    p -= 1
    q += 1
    if q >= mq or -p > mp:
      break
  print(ans)
N = int(input())
A = input()

r_cnt = A.count('R')

ans = 0
for i in range(r_cnt):
    if A[i] != 'R':
        ans += 1

print(ans)
N=int(input())
List=input()
AList=list(List)
RCNT=AList.count("R")
BList=sorted(List)
ANUM=0
BNUM=0
ans=0
i=0
while i<N:
    if AList[i]!=BList[i]:
        ans+=1
    i+=1
print(ans//2)
N = int(input())
S = input()


def calculate(n, s):
    arr = list(s)
    result = []


    leftW = 0
    rightR = arr.count('R')


    if rightR == 0:
        print(0)
        return

    for i in range(n):
        val = arr[i]

        if val == 'R':
            rightR -= 1

        if val == 'W':
            leftW += 1

        result.append(max(leftW,rightR))

    if len(result) == 0:
        print(0)
    else:
        print(min(result))

calculate(N, S)
n = int(input())
s = input()

num_r = s.count("R")
count = 0

for i in range(num_r):
    if s[i] != "R":
        count += 1
    
print(count)
N = int(input())
c = str(input())

w = c.count("W")
rr = c[-w:].count("R")

print(min(w,N-w,rr))
N=int(input())
num=list(input())
num=[0 if i=="W" else 1 for i in num ]
count=0
first=0
for i in num:
    if i==1:count+=1
jk=0
for i in range(count):
    if num[i]==1:
        jk+=1
print(count-jk)
n=int(input())
c=input()
r=c.count("R")#全R
r_1=c[:r].count("R")#左からr番目までのR
#print(r,r_1)
ans=r-r_1
print(ans)
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

N = list(map(int, input().split()))[0]
s = list(input())

w = 0
r = s.count('R')
min_op = max(w, r)
dprint('w, r = ', w, r)

p = 0
while(p < N):
    if (s[p] == 'W'):
        w = w + 1
    else: # (s[p] = 'R')
        r = r - 1
    min_op = min(min_op, max(w, r))
    dprint('p, w, r = ', p, w, r)
    
    p = p + 1

print(min_op)
N = int(input())
RW = input()

j = N-1
count = 0
for i in range(N):
    if RW[i]=='W':
        while i<j:
            if RW[j]=='R':
                count += 1
                j -= 1
                break
            j -= 1

print(count)
num = int(input())
strs = input()
allRs = 0
notAlignedRs = 0
for i in range(num):
    if strs[i] == 'R':
        allRs += 1
for i in range(allRs):
    if strs[i] == 'W':
        notAlignedRs += 1
print(notAlignedRs)
#!/usr/bin/env python3
N = int(input())
S = list(input())

s = 0
e = N - 1

cnt = 0
while s <= e:
    if S[s] == 'W':
        while (S[e] != 'R'):
            if s >= e:
                print(cnt)
                exit()
            e -= 1
        S[s], S[e] = S[e], S[s]
        cnt += 1
    s += 1

print(cnt)
n=int(input())
c=input()
r=c.count('R')
print(c[:r].count('W'))
n=int(input())
c=input()
r=c.count("R")
w=n-r
ans=0
for i,j in zip(c,"R"*r+"W"*w):
    if i!=j:
        ans+=1
print(ans//2)
N=int(input())
S=input()
R=S.count("R")
S=S[:R]
r=S.count("R")
print(R-r)
n = int(input())
c = input()

r = []
w = []

for i in range(n):
    if c[i] == 'R':
        r.append(i)
    else:
        w.append(i)

r.sort(reverse=True)

if len(r) == 0 or len(w) == 0:
    print(0)
else:
    ans = 0
    while ans < len(r) and ans < len(w) and r[ans] > w[ans]:
        ans += 1
    print(ans)
n = int(input())
c = input()

cntR = c.count('R')

print(c[:cntR].count('W'))
n = int(input())
c = input()

lw, rr = [0]*(n+1), [c.count('R')]*(n+1)
for i in range(n):
    lw[i+1] = lw[i] + (c[i] == 'W')
    rr[i+1] = rr[i] - (c[i] == 'R')


def operation(left_white, right_red):
    swap = min(left_white, right_red)
    white_to_red, red_to_white = max(0, left_white-swap), max(0, right_red-swap)
    return swap + white_to_red + red_to_white


print(min(operation(white, red) for white, red in zip(lw, rr)))
n = int(input())
c = list(input())
schw = 0
schr = n-1
ans = 0
while schw < schr:
    while c[schw] != 'W' and schw < n-1:
        schw += 1
    while c[schr] != 'R' and schr > 0:
        schr -= 1
    ans += 1
    c[schw] = 'R'
    c[schr] = 'W'
print(ans - 1)
N=int(input())
S=input()
c=0
d=0
for i in range(N):
    if S[i]=="R":
        c+=1

for j in range(c):
    if S[j]=="W":
        d+=1

for k in range(c,N):
    if S[k]=="R":
        d+=1

if d%2==0:
    print(int(d/2))
else:
    print(int((d+1)/2))
n = int(input())
s = input()
white = 0
red = 0
white_ren = 0
red_ren = 0
for i in range(n):
    if s[i] == "W":
        white += 1
    else:
        red += 1
for i in range(red):
    if s[i] == "R":
        red -= 1
for i in range(white):
    if s[-i - 1] == "W":
        white -= 1
remain = white + red
ans1 = min(red, white)
remain -= 2 * ans1
print(remain + ans1)
N=int(input())
c=list(input())
R=c.count('R')
W=0
ans=max(R,W)
for i in range(N):
    if c[i]=='W':
        W+=1
    else:
        R-=1
    ans=min(ans,max(W,R))
print(ans)
N = int(input())
stone = str(input())
num_red = stone.count('R')
cnt = 0
for i in range(num_red):
    if stone[i] == 'W':
        cnt += 1
print(cnt)
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
c = ns()
aw = c.count('W')
ans = min(n-aw,aw)
w = 0

for i in range(n):
    if c[i] == 'W': w+=1
    rw = aw-w
    rr = n-i-1-rw
    ans = min(ans, max(w,rr))

print(ans)
N = int(input())
c = input()
rnum = 0
okrnum = 0
wnum = 0
for i in range(N):
  if(c[i]=="R"):
    rnum += 1
  else:
    wnum += 1
if(rnum == 0 or wnum == 0):
  print(0)
else:
  for i in range(rnum):
    if(c[i]=="R"):
      okrnum += 1
  #print(rnum , wnum, okrnum)
  #print("ans =",rnum-okrnum)
  print(rnum - okrnum)
N = int(input())
c = list(input())
rr = []
ww = []
for i in range(N):
  if (c[i] == "R"):
    rr.append(i)
  if (c[i] == "W"):
    ww.append(i)

wl = len(ww)
rl = len(rr)
l = min([wl,rl])
ans = 0
for i in range(l):
  if (ww[i] < rr[-i-1]):
    ans += 1

print(ans)
N = int(input())
WR = input()

i = 0
j = len(WR) - 1

num = 0

while(i < j):
  if(WR[j] == "R"):
    if(WR[i] == "W"):
      num += 1
      i += 1
      j -= 1
    else:
      i += 1
  else:
    j -= 1

print(num)
import collections
N = int(input())
stones = list(input())
#print(stones)
c = collections.Counter(stones)
r_s = collections.Counter(stones[:c['R']])
print(c['R']-r_s['R'])
N = int(input())
S = list(input())
i, j = 0, N - 1
res = 0
while i < j:
    while i < j and S[i] == 'R':
        i += 1
    while i < j and S[j] == 'W':
        j -= 1
    if i < j and  S[i] == 'W' and S[j] == 'R':
        S[i], S[j] = S[j], S[i]
        i += 1
        j -= 1
        res += 1
        continue

print(res)
N = int(input())
A = input()
a = A.count("R")
b = A.count("W", 0, a)
print(b)
from collections import deque

N = int(input())
c = input()

rd = deque([i for i, x in enumerate(c) if x == "R"])
wd = deque([i for i, x in enumerate(c) if x == "W"])
if(len(rd) == 0 or len(wd) == 0):
  print(0)
  exit()
count = 0
for i in range(len(c)):
  if(not(wd[0] < rd[-1])):
    break
  rd.pop()
  wd.popleft()
  count += 1
  if(len(rd) == 0 or len(wd) == 0):
    break
print(count)
import math
from decimal import *

n = int(input())
c = str(input())
w = c.count('W')
c = c[::-1]
ans= 0
for i in range(w):
    if(c[i]!= 'W'):
        ans+=1
print(ans)
N = int(input())
stones = input()
red = stones.count("R")
ans = 0
for i in range(red,N):
    if stones[i] == "R":
        ans+=1
print(ans)
n=int(input())
c=input()


a=c.count("R")
l=[c[i] for i in range(a)]
print(l.count("W"))
n=int(input())
c=input()
w=0
for i in range(n):
    if c[i]=="W":
        w+=1
w1=0
t=100
s=0
for i in range(n+1):
    r=n-i-(w-w1)
    if abs(w1-r)==1 and t!=0:
        t=1
        s=w1
    if w1==r:
        t=0
        s=w1
    if i!=n:
        if c[i]=="W":
            w1+=1
print(s+t)
n = int(input())
c=str(input())
if c.count("W") >= c.count("R"):
    C_W =c[:-c.count("W")]
    print(C_W.count("W"))
else:
    C_R =c[c.count("R"):]
    print(C_R.count("R"))
N = int(input())
C = input()

a, b = 0, 0
a = C.count('R')
ans = a

for i in range(N):
	if C[i] == 'R': a -= 1
	else: b += 1
	now = max(a, b)
	ans = min(ans, now)

print(ans)
n=int(input())
s=list(input())
i=0
j=n-1
ans=0
while i<j:
    while s[i]!="W" and i<j:
        i+=1
    while s[j]!="R" and i<j:
        j-=1
    if i<j:
        ans+=1
        i+=1
        j-=1
print(ans)
n=int(input())
s=input()

r = s.count('R')

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

print(ans)
n = int(input())
c = list(input())
w, r = [0] * (n + 1), [0] * (n + 1)
for i in range(n):
    if c[i] == "W":
        w[i + 1] = w[i] + 1
        r[i + 1] = r[i]
    else:
        w[i + 1] = w[i]
        r[i + 1] = r[i] + 1
ans = min(w[n], r[n])
for i in range(1, n):
    x = w[i] - w[0]
    y = r[n] - r[i]
    ans = min(ans, x + abs(x - y))
print(ans)
n = int(input())
c = input()
cnt = [0 for _ in range(n)]
red = 0
for i in range(n):
    if c[i] == 'R':
        red += 1
    cnt[i] = red
print(red - cnt[red-1])
from collections import Counter
n = int(input())
c = list(input())
num = Counter(c)
r = num["R"]

ans = ["R"]*r + ["W"]*(n-r)
cnt = 0

for i in range(n):
    if c[i] != ans[i]:
        cnt += 1
        
print(cnt//2)
n = int(input())
c = str(input())
l = 0
r = n-1
answer = 0
while l < r:
    if c[l] == "W" and c[r] == "R":
        answer += 1
        l += 1
        r -= 1
    elif c[l] == "W" and c[r] == "W":
        r -= 1
    elif c[l] == "R" and c[r] == "R":
        l += 1
    else:
        l += 1
        r -= 1
print(answer)
import sys
N = int(input())
word = input()
if word.count('W') == N:
  print(0)
  sys.exit()
num_R = word.count('R')
num_W,min_count= 0,float('inf')
for i in range(N):
  if word[i] == 'W':
    num_W += 1
  else:
    num_R -= 1
  min_count = min(min_count,max(num_W,num_R))
print(min_count)
def main():
    N = int(input())
    S = input()
    
    r = S.count("R")
    ans = S[r:].count("R")
    print(ans)
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()
def d1(x):
  if x == "R":
    return 0
  else:
    return 1

N = int(input())
C = list(map(d1,input()))
w = sum(C)
r = N - w

if sum(C[:r]) < w:
  print(sum(C[:r]))
else:
  print(w)
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
mychr = input().rstrip()

result = float('inf')
red = 0
for i in mychr:
    if i == "R":
        red += 1

R = 0
W = 0

for index, i in enumerate(mychr):
    if i == "R":
        R+=1
    else:
        W+=1
    temp = max(W,red-R)
    result = min(result, temp)

if W != n:
    print(result)
else:
    print(0)
from itertools import accumulate

n = int(input())
s = input()

left_w = [0]
for c in s:
    if c == 'W':
        left_w.append(1)
    else:
        left_w.append(0)
left_w = list(accumulate(left_w))

right_r = [0]
for c in s[::-1]:
    if c == 'R':
        right_r.append(1)
    else:
        right_r.append(0)
right_r = list(accumulate(right_r))
right_r.reverse()

print(min(map(max, zip(left_w, right_r))))
N = int(input())
S = list(input().strip())

l = 0
r = N-1
ans = 0
while l < r:
    if S[l] == 'W' and S[r] == 'R':
        ans += 1
        l += 1
        r -= 1
    while l < N and S[l] != 'W':
        l += 1
    while r >= 0 and S[r] != 'R':
        r -= 1

print(ans)
n=int(input())
s=input()
red=s.count('R')
white=s.count('W')
mn=min(red,white)
ct=0
for i in range (red):
    if s[i]=='W':
        ct+=1
mn=min(mn,ct)
print(mn)
import sys
sys.setrecursionlimit(10**6)

n = int(input())
C = input()

C = list(C)

d = {0:0}
tot = 0

for i,c in enumerate(C):
    if c == 'R':
        tot += 1
    d[i+1] = tot

ans = tot-d[tot]
print(ans)
n=int(input())
c=input()
a=c.count("R")
print(a-(c[:a].count("R")))
n = int(input())
rw = input()
red = rw.count('R')
ans = rw[:red].count('W')
print(ans)
N=int(input())
stone= list(input())
white_number=sum(x=='W' for x in stone)
stone.reverse()
ans=0
for i in range(white_number):
    if stone[i] != 'W':
        ans+=1
print(ans)
import sys
readline = sys.stdin.readline

N = int(readline())
C = readline().rstrip()

ans = 0
left = 0
right = N - 1

while left < right:
  # Wを見つけるまで左からカーソル移動
  if C[left] == "R":
    left += 1
    continue
  while left < right and C[right] == "W":
    right -= 1
  if left == right:
    break
  ans += 1
  left += 1
  right -= 1
  
print(ans)
a=int(input())
v=input()
b=v.count("R")
c=0
for i in v[:b]:
    if i!="R":
        c+=1
print(c)
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
s = list(ins())
t = sorted(s)
ans = 0
for i in range(n):
    if t[i] != "R":
        break 
    if s[i] != t[i]:
        ans += 1
print(ans)
n = int(input())
stones = input()
left = 0
right = n-1

ans = 0
while True:
  while left < n and stones[left] == 'R':
    left += 1
  while right > 0 and stones[right] == 'W':
    right -= 1
  if left < n and right > 0 and left < right:
    left += 1
    right -= 1
    ans += 1
  else:
    break
print(ans)
n = input()
m = input()
maxr = m.count("R")
maxw = m.count("W")

min_move = len(m)
max_r = m.count("R")
max_w = m.count("W")
right = 0
left = 0
for i in range(len(m)):
    if m[i] == "W":
        left += 1
    else:
        max_r -= 1
    if max(left,max_r) < min_move:
        min_move = max(left,max_r)
if maxw == 0 or maxr == 0:
    print(0)
else:
    print(min_move)
n=int(input())
c=list(input())
num=c.count("R")
ans=num
for i in range(num):
    if c[i]=="R":
        ans-=1
print(ans)
import sys
input = sys.stdin.readline
N = int(input())
S = list(input())[: -1]
r = S.count("R")
res = 0
for i in range(r):
  if S[i] != "R": res += 1
print(res)
from math import floor, ceil
N = int(input())
WHITE = 0
RED = 1
str = list(map(str, list(input())))
r = []
w = []

for i in range(N):
  w.append(i) if str[i] == "W" else r.append(i)
  str[i] = WHITE if str[i] == "W" else RED
r.reverse()
max_count = min(len(r), len(w))
count = 0
for i in range(max_count):
  if r[i] - w[i] > 0:
    count += 1

print(count)
N = int(input())
c = list(input())
num_r = 0
for ci in c:
    if ci == 'R':
        num_r += 1
ans = 0
if num_r != N and num_r != 0:
    for i in range(num_r):
        if c[i] == 'W':
            ans += 1
print(ans)
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())
C = input()

left = 0
right = N-1
count = 0

while left < right:
    if C[left] == 'W' and C[right] == 'R':
        count += 1
        left += 1
        right -= 1

    if C[left] == 'R':
        left += 1
    if C[right] == 'W':
        right -= 1

print(count)
N=int(input())
S=input()
ans=0
i=0
j=N-1
while i<j:
  while i<N:
    if S[i]=='W':
      break
    else:
      i+=1
  while j>0:
    if S[j]=='R':
      break
    else:
      j-=1
  if i<j:
    ans+=1
    i+=1
    j-=1
print(ans)
n = int(input())
s=input()
isi=[]
for i in s:
    isi.append(i)

R_kosuu=isi.count("R")
irekaekosuu=0
for i in range(R_kosuu):
    if isi[i]=="W":
        irekaekosuu+=1


print(irekaekosuu)
n = int(input())
c = list(input())

r = c.count('R')  
wr = c[:r].count('W')  

print(wr)
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())
c = input()

# 求解処理
w = 0
r = c.count("R")
ans = max(w, r)
for n in range(N):
    c_n = c[n]
    if c_n == "W":
        w += 1
    else:
        r -= 1
    ans = min(ans, max(w, r))

# 結果出力
print(ans)