peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
c_l = list(input())

l = 0
r = n-1
w_n = 0
r_n = 0

while l < r:
    if c_l[l] == 'W':
        w_n += 1
    if c_l[r] == 'R':
        r_n += 1
    l += 1
    r -= 1

if w_n == 0:
    print(0)
else:
    print(max(w_n, r_n))
n=int(input())
l=list(map(str,input().split()))
c=list("".join(l))
w=c.count('W')
cc=c[-w:]
r=cc.count('R')
print(r)
n=int(input())
stone=str(input())
count=0
for i in range(n-1):
    if  stone[i]=='W' and stone[i+1]=='R':
        count=count+1
        m=1
        while m<=i and stone[i-m]=='W':
            if stone[i-m-1]=='W':
                count=count+1
                m=m+1
            else:
                m=m+1
print(count)
n = int(input())
c = list(input())#ciが R のとき赤、W のとき白
count = 0


for i in range(n-1):
  #print(c)
  if c[i] == "W" and c[i+1] == "R":
    c[i] = "R"
    count += 1
print(count)
n = int(input())
c = input()
W_all = c.count("W")
R_all = c.count("R")
W_0 = c[0 : 0].count("W")
R_0 = c[0 : n].count("R")

tmp = n
W = W_0
R = R_0
for i in range(n):
    #print(W, R)
    if c[i] == "W":
        W += 1
        R = R
    elif c[i] == "R":
        W = W
        R -= 1

    if tmp >= max([W ,R]):
        tmp = max([W, R])

print(tmp)
n=int(input())
a=input()
con=0
ans=n
for i in range(n):
  if i==ans:
      break
  if a[i]=="W":
    con+=1
    while ans>=0:
      ans-=1
      if i==ans:
        print(con)
        exit()
      if a[ans]=="R":
        break  
print(con)
n=int(input())
c=list(input())
r=0
for i in range(n):
     if c[i]=='W':
          r=i
num=0
for i in range(n):
     if c[i]=='W':
          num+=1

if num>=n-r:
     print(num-1)
else:
     print(num)
n = int(input())
s = list(input())
num = 0
k = -1
for i in range(1,n):
  if i + k >= n-1:
    break
  if s[-i] == 'R':
    j = k+1
    while True:
      if j +i == n-1:
        k = j
        break
      if s[j] == 'W':
        s[j] = 'R'
        s[-i] = 'W'
        k = j
        num += 1
        break
      j += 1
      

print(num)
#!/usr/bin/env python3
"""
RWとなってなければおｋ
WRはだめ
"""


def main():
    import sys

    input = sys.stdin.readline

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

    white, red = 0, c.count('R')
    ans = N
    for i in range(N):
        if c[i] == 'W':
            white += 1
        else:
            red -= 1
        res = max(white, red)
        ans = min(ans, res)
    print(ans)


if __name__ == '__main__':
    main()
def main():
    n = int(input())
    c = input()
    w = c.count("W")
    ans = 0
    for i in range(n):
        target = "R" if i < w else "W"
        if c[i] != target:
            ans += 1
    print(ans // 2 if 0 < w < n else 0)


if __name__ == '__main__':
    main()
n=int(input())
c=list(str(input()))

count=0
w_count=0
r_count=0
w_count2=0
r_count2=0
flag=False

for i in range(n//2):
	if c[i]=="W":
		w_count+=1
	else:
		r_count+=1
for i in range(n//2,n):
	if c[i]=="W":
		w_count2+=1
	else:
		r_count2+=1
if r_count2>=w_count:
	print(w_count)
else:
	print(r_count+r_count2)
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
print(ans)
n=int(input())
a=list(input())
c=a.count("W")
b=a[:n-c]
d=b.count("W")
print(d)
print(b)
n = int(input())
al = list(input())
cr = al.count('R')
cr2 = cr//2
ans = 0
flag = False
flag2 = False
for a in al[::-1]:
    if a == 'R':
        cr2 -= 1
    if cr2 == 0:
        flag = True
        continue

    if flag and not flag2 and a == 'R':
        flag2 = True
        continue

    if flag2 and a == 'W':
        ans += 1

print(ans)
n = int(input())
line = list(input())
if 'W' not in line or 'R' not in line:
    print(0)
else:
    ans = min(line.count('W'),line.count('R'))
    for i in range(n):
        if line[i] == 'R':
            w = line[:i].count('W')
            r = line[i+1:].count('R')
            if ans <= min(ans,abs(w-r)+min(w,r)):
                ans = min(ans,abs(w-r)+min(w,r))
                break
    print(ans)
n = int(input())
c = input()
ans = 0
c1 = len(c)//2 if len(c)%2 == 0 else len(c)//2 +1
cnt_w = 0
cnt_r = 0
for i in range(c1):
  if c[i]=='W':
    cnt_w += 1
for i in range(c1,len(c)):
  if c[i]=='R':
    cnt_r += 1

ans = cnt_w if cnt_w <= cnt_r else cnt_r

print(ans)
N = int(input())
l = list(input())
 
rev = 0
 
# for i in range(1, len(l)-1):
#   if l[i-1] == 'W' and l[i] == 'R':
#    l.insert(0, l.pop(i))
 
rl = l.count('R')
wl = l.count('W')
 
print(rl if rl < wl else wl)
N = int(input())
c= list(input()) 
if c.count('R') == N:
	print(0)
div=0
if N %2 == 1:
	div =1
clist_L = c[:int(N/2)]
clist_R = c[int(N/2)+div:]
Lcnt = clist_L.count('W')
Rcnt = clist_R.count('R')
if Lcnt - Rcnt <=0:
	print(Rcnt)
else:
	print(Lcnt)
import sys
import numpy as np
N=int(input())
data = input()
num = len(data)
list_data = list(data)
R_num = list_data.count('R')
W_num = num-R_num

if(R_num==0 or W_num==0):
  print('0')
  sys.exit()
  
count = 0
flag=0
while(count<=N//2):
  
  list_R = [i for i, x in enumerate(list_data) if x == 'R']
  last_R = list_R[-1]
  first_W = list_data.index('W')
  if last_R-first_W==1:
    break
    
  else:
    list_data[last_R]='W'
    list_data[first_W]='R'
    count +=1
    
print(count+1)
N=int(input())
S= list(input())
W_count=S.count('W')
R_count=S.count('R')
if((W_count==0) or (R_count==0)):
    print(0)
else:
    if(len(S)%2==0):
        print(min(W_count,R_count-S[:len(S)//2].count('R')))
    else:
        print(min(W_count,R_count-S[:len(S)//2+1].count('R')))
N = int(input())
S = input()


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

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



    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(-1)
    else:
        print(min(result))

calculate(N, S)
n = int(input())
s = list(input())
#s = s[::-1]
from itertools import groupby
li = []
for k,v in groupby(s):
    li.append(list(v))
#print(li)
cnt = 0

for i in range(len(li)//2):
    cnt += min(len(li[i]),len(li[i+1]))
print(cnt)
n = int(input())
c = input()
wc = c.count('W')
rc = c.count('R')
print(min(c[:rc].count('W'), c[wc:].count('R')))
N = int(input())

C = input()

if N % 2 == 0:
  mid = N//2
else:
  mid = N//2+1

Wcount = C.count("W", 0, mid)
print(Wcount)
n = int(input())
s = input()
res = 2000000 
for i in range(1,n):
	w = s.count('W',0,i)
	r = s.count('R',i)
	if (max(r,w) < res):
		res = max(r,w)

print(str(res))
n = int(input())
c = list(input())
 
if n % 2 == 0:
  half = int(n / 2)
  odd =0
else:
  half = int((n-1) / 2)
  odd = 1
pre_w_num = 0
for i in range(half):
  if c[i] == "W":
    pre_w_num = pre_w_num + 1
post_r_num = 0
for j in range(half):
  if c[-1 *(j+1)] == "R":
    post_r_num = post_r_num +1
if pre_w_num > post_r_num:
  ans = pre_w_num
else:
  ans = post_r_num
if odd == 1:
  if c[half] == 'W':
    ans = ans +1
print(ans)
N=int(input())
C = input()
print(C.count('WR'))
N = int(input())
c = input()
print(min(c.count("W"), c.count("R"), c[:c.count("W")].count("W")))
if __name__ == '__main__':

    n = int(input())
    A = list(input())

    white = A.count("W")
    red = A.count("R")

    ans = 0
    if red > white:
        ind = n // 2 + 1
    else:
        ind = n // 2

    left = A[:ind]
    ans = left.count("W")
    print(ans)
K = int(input())
C = input()
C = list(C)
r = C.count("W")
A = C[:r].count("W")
B = C[-K+r:].count("W")
# print(A)
# print(B)
cnt = 0
for _ in range(200000):
    if A > 0:
        if B > 0:
            A -= 1
            B += 1
            cnt += 1
        else:
            A -= 1
            cnt += 1
    else:
        break
print(cnt)
import sys
input = sys.stdin.readline
n = int(input())
s = list(input())
ans = 0
for i in range(n - 1):
  idx = n - 2 - i
  if s[idx] == 'W' and s[idx + 1] == 'R':
    ans += 1
    s[idx] = 'R'
print(ans)
n = int(input())
wr = input()

j = n
ans = 0
for i in range(0,n):
  if wr[i] == 'W':
    while j>=1:
      j-=1
      if wr[j] == 'R':
        ans+=1
        break
print(ans)
n=int(input())
s=input()
c=0
for i in range(len(s)-1):
  if(s[i]=='W' and s[i+1]=='R'):
    c+=1
print(c)
n=int(input())
c=list(input())
f=0
f2=0
wcnt=0
wcnt2=0
rcnt=0
cnt=0
for i in range(n):
    if f and c[i]=="R":
        cnt+=1
    if c[i]=="R":
        f=1
        rcnt+=1
    if c[i]=="W":
        wcnt2+=1
    if f==0 and c[i]=="W":
        wcnt+=1
ans=[rcnt,wcnt2]
if cnt>=wcnt:
    ans.append(cnt)
print(min(ans))
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
s = rr()
print(s[n//2].count('W'))
n=int(input())
c=input()
f=False
wb=wc=0
rb=rc=0
 
for i in range(n):
  if c[i]=="R":
    rc += 1
  else:
    wc += 1
 
for i in range(n):
  if c[i]=="W":
    f=True
  else:
    rc-=1
 
  if f:
    if c[i]=="R":
      rb+=1
      rc-=1
    else:
      wb+=1
      wc-=1
 
    if wb==rc:
      print(wb)
      exit()
 
print(rb)
N = int(input())
C = input()
R = C.count("R")
C = C[:len(C)//2]
W2 = C.count("W")
print(min(R, N - R) if W2*2 > N else min(min(R, N - R),W2))
n = int(input())
A = input()
a = A.count('W')
b = A.count('R')
c = A[:n//2]
d = c.count('W')
print(min(a,b,d))
N = int(input())
c = list(input())
count = 0

def getLeftR(c, currentIndex):
    for i in range(currentIndex+1, N):
        if c[i] == 'W':
            return i
    return -1

for i in range(N-1):
    if c[i] == 'W' and c[i+1] == 'R':
        leftWindex = getLeftR(c, i+1)
        if leftWindex > 0:
            c[leftWindex], c[i+1] = c[i+1], c[leftWindex]
            count += 1
        else:
            break
print(count)
n=int(input())
c=list(input())
ans=0
flag=0
for i in c:
  if i=="W":
    flag+=1
  elif flag==0 and i=="R":
    pass
  else:
    flag-=1
    ans+=1
cnt=0
for i in range(n-1):
  if c[i]=="W" and c[i+1]=="R":
    cnt+=1
print(ans-cnt//2)
n = int(input())
clist = input()

rs = clist.count("R")
ws = clist.count("W")

sort_rs = rs - clist[0:rs-1].count("R")

ans = 10**7

if rs < ans:
    ans = rs
if ws < ans:
    ans = ws
if sort_rs < ans:
    ans = sort_rs
print(ans)
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    a = input()

    if not 'WR' in a:
        print(0)
    else:
        rightmostW = a.find('RW')
        wnum = a[rightmostW+1:].count('R')
        leftmostR = a.rfind('R')
        wnum2 = a[:leftmostR+1].count('W')
        r = min(wnum, wnum2)
        print(r)

if __name__ == '__main__':
    main()
n = int(input())
c= input()

ans1=c.count("R")
ans2=c.count("W")

ans3=0
for i in range(n//2):
    if c[i]=="W":
        ans3+=1

print(min([ans1,ans2,ans3]))
N = int(input())
S = input()

wl = 0
for i in range(N):
  if S[i] == "W":
    wl += 1

rl = N - wl
    
l = 0
if N % 2 == 0:
  for i in range(N//2):
    if S[i] == "W":
      l += 1
else:
  for i in range(N//2):
    if S[i] == "W":
      l += 1

print(min([wl, rl, l]))
N = int(input())
S = input()

l = 0
r = len(S) - 1

W = 'W'
R = 'R'

cnt = 0
while l < r:
    if S[l] == R:
        l += 1
        continue
    else:
        while l < r:
            if S[r] == W:
                r -= 1
                continue
            else:
                cnt += 1
                l += 1
                r -= 1

print(cnt)
n = int(input())
c = input()
def try_count(c, color):
    try:
        return c.count(color)
    except:
        return 0
all_r = try_count(c, 'R')
all_w = try_count(c, 'W')
left_w = try_count(c[:all_w], 'W')
print(min(all_r,all_w,left_w))
#!/usr/bin/env python3

N = int(input())
stones = input()


def count_WR(stones):
    return stones.count('WR')


def solve(stones):
    if count_WR(stones) == 0:
        return 0

    count = 0

    # 左端のWをRにする
    if stones[0] == 'W':
        stones = 'R' + stones[1:]
        count += 1

    count += count_WR(stones)

    return count


print(solve(stones))
n=int(input())
c=list(input())
lc=len(c)
if "W" not in c or "R" not in c:
    print(0)
else:
    ctr = c.count("R")
    if c[0] == "W":
        print(min(ctr-1, lc-ctr))
    else:
        c.pop(0)
        print(min(ctr, lc-ctr))
n=int(input())
s=input().strip()
R=s.count('R')
t=0
for i in range(R):
    if s[i]=='W':
        t=t+1
u=R-(n-R-t)
f=max(t,u)
if R==0 or R==n or t==R:
    f=0
print(f)
n = int(input())
c = input()

wi = c.find('W') + 1
ri = c.rfind('R')

if wi == -1 or ri == -1:
    print(0)
else:
    ans = 0
    while wi < ri:
        wi = c[wi:].find('W') + wi
        ri = c[:ri].rfind('R')
        ans += 1

    print(ans)
n = int(input())
C = input()

ans = 0
if C[0] == 'W':
    ans += 1

c = C[1::]

for i in range(len(c) - 1):
    if c[i] == 'W' and c[i + 1] == 'R':
        ans += 1

print(ans)
n = int(input())
s = input()
ans = 0
right = n-1
for i in range(n//2):
    if s[i] == "W":
        while right > i:
            if s[right] == "R":
                ans += 1
                right -= 1
                break
            else:
                right -= 1

print(ans)
# -*- coding: utf-8 -*-

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

J=0
ans=0
for i in range(N):
    if C[i]=="W":
        for j in range(J,N):
            if i+j>N:break
            if C[N-1-j]=="R":
                ans+=1
                #print(i,N-1-j)
                J=j+1
                break

    if i+J>N:break
    
print(ans)
a=int(input())
b=input()
c=int(a/2)
d=0
e=a-1
i=0
while True:
    if b[i]=='W':
        for j in range(0,e+1)[::-1]:
            if b[j]=='R':
                d=d+1
                e=j-1
                break
    i=i+1
    if i+1>=e: break
print(d)
a=int(input())
b=input()
c=int(a/2)
d=0
e=a-1
i=0
while True:
    if (b[i]=='W'):
        for j in range(0,e+1)[::-1]:
            if b[j]=='R':
                d=d+1
                e=j-1
                break
    i=i+1
    if i>e: break
print(d)
#n,d=map(int,input().split())
#xy = [list(map(int,input().split())) for i in range(n)]
n=int(input())
c=list(input())
left=0
right=0
for i in range(0,n//2+1):
  if c[i]=="W":
    left+=1
  
for i in range(n//2+1,n):
  if c[i]=="R":
    right+=1
ans1=left+right-min(left,right)
aru=0
for i in range(n):
  if c[i]=="R":
    aru+=1
dab=n-aru

print(min(ans1,aru,dab))
n=int(input())
s=input().strip()
R=s.count('R')
t=0
for i in range(R):
    if s[i]=='W':
        t=t+1
u=R-(n-R-t)
f=max(t,u)
if R==0 or R==n:
    f=0
print(f)
import sys
import heapq

def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    C = list(input())

    Wcount=0
    Rcount =0
    rr =C.count("R")
    ww =C.count("W")


    for j in range(ww):
        if C[j]=="W":
            Rcount+=1

    for i in range(rr):
        if C[-1-i]=="R":
            Wcount+=1

    print(max(Rcount,Wcount))






if __name__ == "__main__":
    main()
in_num = int(input())

if in_num % 2 == 0:
    print(-1)
    exit()
elif in_num % 5 == 0:
    print(-1)
    exit()

# 数列のスタート位置を探す
ans = 1
s = 1
while s * 7 < in_num:
    s = int(str(s) + "1")
    ans += 1

import math

while True:
    x = math.gcd(in_num, s * 7)
    if x == 1:
        s = int(str(s) + "1")
        ans += 1
    else:
        print(ans)
        exit()
N = int(input())
c = list(input())
pre = c[0:(N+1)//2]
suf = c[(N+1)//2:N]
ans = 0

pre_cnt = pre.count('W')
suf_cnt = suf.count('R')

ans = min(pre_cnt,suf_cnt)

print(ans)
N = int(input())
C = list(input())

w = C[:N//2].count("W")

if N%2 == 0:
  r = C[N//2:].count("R")  
else:
  r = C[N//2+1:].count("R")
  
print(max(w,r))
N = int(input())
c = str(input())

w = c.count("W")
r = c.count("R")

ans = r

if w == 0:
    print(0)
else:
    if c[0]=="R":
        for i in range(N):
            if c[i] == "W":
                ans -= i
                print(ans)
                break
            break
N = int(input())
S = input()

ans = 0
cnt = [0, 0]
for i in range(N):
    if S[i] == "W":
        if i > 0 and S[i - 1] == "R":
            ans += min(cnt)
            cnt = [0, 0]
        cnt[0] += 1
    else:
        cnt[1] += 1
ans += min(cnt)
print(min(ans, S.count("W"), S.count("R")))
n = int(input())
c = input()
n = len(c)//2
ans = max(c.count('W',0,n), c.count('R',n,n*2))
print(ans)
num = int(input())
stn = list(input())
num_W = stn.count('W')
num_R = stn.count('R')
cnt = 0

if num_W >= num_R:
    for i in range(num_R):
        if stn[i] == "W":
            cnt += 1

else:
    for i in range(num_W):
        if stn[-i] == "R":
            cnt += 1

print(cnt)
N = int(input())
c = input()
a = c[0:len(c)//2]
if ("W" not in c) or ("R" not in c):
  print(0)
  exit()

print(c.count("R")-a.count("R"))
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    s = i = 0
    while True:
        i += 1
        s = (s*10 + 7) % k
        if s % k == 0:
            print(i)
            break
# Nとcの定義
N = int(input())
C = input()

# 赤色の個数
red_num = str.count(C, "R")

# 左からred_num個までに含まれる白色の個数
white_num_left = str.count(C[:red_num], "W")

# 最小の操作回数
min_ope = white_num_left

# 最小の操作回数の出力
print("最小の操作回数: " + str(min_ope))
n = int(input())
C = list(input())

if "R" not in C:
    print(n)
    exit()

W = C.count("W")
R = C.count("R")
w = 0
r = R
ans = float('inf')

for c in C:
    if c == "W":
        w += 1
    else:
        r -= 1
    ans = min(ans, max(w, r))
print(ans)
import collections

N = int(input())
cs = list(input())


count_R = cs.count("R")
count_W = cs.count("W")

W_check = cs[: count_W]
R_check = cs[count_R:]

print(min(W_check.count("W"), R_check.count("R")))
N=int(input())
c=list(input())
c1=c[::-1]
ans=0

w_index=[i for i, x in enumerate(c) if x=="W"]
r_index=[i for i, x in enumerate(c1) if x=="R"]

for i in range(len(r_index)):
    r_index[i]=N-1-r_index[i]


if "R" in c and "W" in c:
    for i in range(min(len(r_index),len(w_index))):
        w=w_index[ans]
        r=r_index[ans]
        if w-r==1:
             ans=ans-1
             break
        ans+=1

print(ans)
import re

n = int(input())
c = input()

def set_c(a):
    a = re.sub('^[R]*W', 'W', a)
    a = re.sub('R[W]*$', 'R', a)
    return a

c = set_c(c)
l1 = len(c)//2
l2 = (len(c)+1)//2

print(min(c[:l1].count('W'),c[l2:].count('R')))
n = int(input())
s = list(input())
cnt = 0
for i in s:
    if i == "R":
        cnt += 1
    else:
        break

print(s.count("R")-cnt)
n = int(input())
c = input()

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

print([w[i]+r[i]-min(w[i],r[i]) for i in range(0,n+1)])
n = int(input())
s = input()
a = [c for c in s]
ans = 0
t1 = a.count('W')
t2 = a.count('R')
ans += (t1*t2)//n + 1
print(ans)
N=int(input())
c=input()
r=c.count("R")
w=c.count("W")

if w==0 or r==0:
    print(0)
else:
    ans=w
    cnt=0
    for i in range(N-1,N-w,-1):
        cnt+=(c[i]=="W")
        test=i-cnt+w-i
        ans=min(ans,test)
    print(ans)
s = input()
R_num = s.count("R")
s[:R_num].count("W")
C = list(input())
C_ = sorted(C)

wr = rw = 0
for i in range(len(C_)):
    if C[i] != C_[i]:
        if C[i] == 'R' and C_[i] == 'W':
            rw += 1
        else:
            wr += 1

print(max(wr, rw))
import sys
from itertools import groupby
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    c=list(input())
    ans=0
    white=0
    for key, value in groupby(c):
        if key=='W':
            white=len(list(value))
        else:
            ans+=min(white,len(list(value)))
    print(ans)   
 
 
 
if __name__=='__main__':
    main()
N = int(input())
c = input()

count = 0
for i in range(1, N):
    if c[i] == 'W':
        count += 1
print(count)
n=int(input())
s=input()
c=0
for i in range(1,n):
  if(s[i]=='R'and s[i-1]=='R'):
    c+=1
print(c)
N = int(input())
tmpN = N
C = input()
if N % 2 == 1:
  N -= 1
  N = int(N / 2)
  result = C.count('R',N)
  if C[N+1] == 'R' and C[N] == 'R':
    result += 1
else:
  N = int(N / 2)
  result = C.count('R',N)

if C.count('R') == tmpN:
  print('0')
else:
  print(result)
N=int(input())
List=list(input())
a=0
for i in range(N-1):
    if List[i]=="R":
        pass
    else:
        if List[i+1]=="W":
            pass
        else:
            List[i+1]="W"
            a+=1
print(a)
import sys
n = int(input())
s = list(input())

if (s.count("R") == 0 or s.count("W") == 0):
    print(0)
    sys.exit()

middle = int(len(s) // 2)

rr = s[middle:].count("R")
rw = len(s) - rr
lr = s[0:middle].count("R")
lw = len(s) - lr

if (rr == lw):
    print(rr)
    sys.exit()

if (rr > lw):
    print(lw)
    sys.exit()

if (rr < lw):
    print(rr)
    sys.exit()
n  = int(input())
c = list(input())


rcnt = c.count('R')
wcnt = c.count('W')

ans = 0
if set(c) == {'R'} or set(c) == {'W'}:
    print(0)
else:
    cnt = 0
    for i in range(n//2):
        if c[i] == 'R':
            cnt += 1
    
    print(rcnt - cnt)
n = int(input())
c = input()
l = 0
j = 0
a = [0]*n
b = [0]*n
for i in range(n):
  if(c[i]=='W'):
    a[l] =i+1
    l +=1
l = 0
for i in range(n-1,0,-1):
  if(c[i]=='R'):
    b[j] = i+1
    j +=1
j = 0
while(a[l] < b[l]):
      a[l]=0
      b[l]=0
      l+=1
      j+=1
print(j)
n=int(input())
s=input()
if s.count('R')==0 or s.count('W')==0:
    print(0)
else:
    a= s.count('W')
    w=s.index('W')
    b= s[w:].count('R')
    if b==0:
        print(0)
    else:
        c = s[(w+1):].count('W')
        t=min(b,c)
        print(min(t,a))
n = int(input())
s = input()
nw = len(s.replace('R',''))
nr = n - nw

tmp_w = 0
ret = n
w_left = 0
for i, c in enumerate(s):
    if c == 'W':
        w_left += 1
    r_right = n - 2*i - 2 +  w_left
    ret = min(ret, max(r_right, w_left))
print(ret)
n = int(input())
c = input()
n = len(c)//2
ans = min(c.count('W',0,n), c.count('R',n,n*2))
print(ans)
N = int(input())
C = list(input())
N1 = int(N/2)
C1 = C[0:N1]
C2 = C[N1:N]
count = 0
if (C1.count('W') == C2.count('R')):   #左右対象のとき
    count = C1.count('W')
elif(C1.count('R') == C2.count('W')):
    count = C.count('W')
print(count)
n = int(input())
c = input()

rtow = c.count('R')
wtor = 0

anses = []
for i in range(n):
  if c[i] == 'W':
    wtor += 1
  else:
    rtow -= 1
  anses.append(max(rtow, wtor))

print(min(anses))
N=int(input())
c=input()
r=c.count("R")
w=c.count("W")

if w==0 or r==0:
    print(0)
else:
    ans=w
    cnt=0
    for i in range(N-1,N-w,-1):
        cnt+=(c[i]=="W")
        test=N-i-cnt+(w-cnt-(N-i-cnt))
        ans=min(ans,test)
    print(ans)
def q4():
    n = int(input())
    line = input()
    if 'WR' in line:
        r = line.count('R')
        safe = line[0:r-1].count('R')
    else:
        r = 0
        safe = 0
    print(r-safe)

if __name__ == "__main__":
    q4()
n = int(input())
c = list(input())
w = 0
r = c.count("R")
ans = n
for i in range(n) :
    if c[i] == "W" :
        w += 1
    else :
        r -= 1
    if ans > max(w,r) :
        ans = max(w,r)

print(ans)
# coding: utf-8
# Your code here!
N=int(input())
S=list(input())

print(S[:N//2].count("W"))
n=int(input()) 
s=input()
a=[]
r,w=0,0
ans=float("inf")
for i in range(n):
    if s[i]=="R":
        r+=1
    else:
        w+=1
    a.append([r,w])
for i in range(n):
    r1,w1=a[i][0],a[i][1]
    r2,w2=r-r1,w-w1
    t=min(w1,r2)
    tmp=t+max(w1-t,0)+max(r2-t,0)
    if tmp<ans:
        ans=tmp
print(ans)
n = int(input())
al = list(input())
cr = al.count('R')
cw = al.count('W')
if cr == 0 or cw == 0:
    print(0)
    exit()


def ceil(a, b):
    return -(-a // b)


ans = 0
cr = cr // 2 + 1
for a in al[::-1]:
    if a == 'W':
        cr -= 1
        ans += 1
    if cr == 0:
        break

print(ans)
import math
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
print(c)


num=0
for i in reversed(range(N)):
    if c[i]=='R' :
        for u in (range(num,i)):
            if c[u]=='W':
                c[u]='y'
                c[i]='W'
                num+=1
                break
            
print(c)
print(num)