peterverebics/CodeNet_Python_118 huggingface dataset:
k = int(input())
s = input()

if len(set(s)) == 1:
    print(0)
    exit()

left_r = s[:k//2].count('R')
left_w = (k//2) - left_r

right_r = s[k//2:].count('R')
right_w = (k//2) - right_r

res = min(left_w, right_r)

if right_r and not left_w and (k % 2 and s[k//2] == 'W'):res+=1

print(res)
N = int(input())
C = input()

count = 0
r = 0
w = 0
for i in range(N // 2):
    c = C[i]
    if c == "W":
        if r > 0:
            r -= 1
            count += 1
        else:
            w += 1
    c = C[N-i-1]
    if c == "R":
        if w > 0:
            w -= 1
            count += 1
        else:
            r += 1
ans = count + w
print(ans)
n = int(input())
cs = input()

cand1 = cs[:cs.count('R')].count('W')
cand2 = cs[cs.count('W'):].count('R')
if cand1 > cand2:
  print(min(cand1, cand2))
else:
  print(max(cand1, cand2))
n=int(input())
c=input()
n_R=c.count('R')
n_W=0
temp=n_R
ans=1000000007
for i in range(n):
    if c[i]=='W':
        n_W+=1
    else:
        n_R-=1
    temp=max(n_W,n_R)
    ans=min(temp,ans)
print(ans)
n = int(input())
c = list(input())

count = 0
for i in range(n//2):
    if c[n-1-i] == 'R':
      for j in range(n//2):
        if c[j] == 'W':
          c[i] = 'W'
          c[j] = 'R'
          count += 1
          break
        
print(count)
N = int(input())
C = list(input())
N1 = int(N/2)
C1 = C[0:N1]
C2 = C[N1:N]
count = 0
if (C1.count('W') == 0 and C1.count('R') == 0 and
       C2.count('W') == 0 and C2.count('R') == 0):
    count = 0
elif (C1.count('W') == C2.count('R')):   #左右対象のとき
    count = C1.count('W')
elif(C1.count('R') == C2.count('W')):
    count = C.count('W')
else:
    if(C.count('W') > C.count('R')):
        count = C.count('R')
    else:
        count = C.count('W')
print(count)
def solve():
    n = int(input())
    c = input()

    x = c.count('R')
    if x == n or x == 0: return 0

    w1 = 0
    for i in range(n):
        if c[i] == 'W':
            w1 += 1
        else:
            break
    
    return max(x-1, w1)
print(solve())
n = int(input())
c = input()
w = 0
r = c.count('R')
ans = n
for i in c:
    if i == 'W': w += 1
    else: r -= 1
    ans = min(ans, max(w, r))
print(ans)
N = int(input())
c= list(input()) 
if c.count('R') == N:
	print(0)
	exit()
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-Rcnt)
n=int(input())
s=input()
print(max(s[:n//2].count('W'),s[n//2:].count('W')))
n=int(input())
s=input()
l,r=0,n-1
ans=0
while r>l:
 while l<n and s[l]=="R":
  l+=1
 while r>0 and s[r]=="W":
  r-=1
 if l<n and r>0 and s[l]=="W" and s[r]=="R":
  ans+=1
  l+=1
  r-=1
print(ans)
n = int(input())
c = input()
left, right = 0, n - 1
cnt = 0
while left <= right:
    while left < n and c[left] == 'R':
        left += 1
    while right > -1 and c[right] == 'W':
        right -= 1
    if left == n or right == -1: break
    left += 1
    right -= 1
    cnt += 1
print(cnt)
n=int(input())
c=list(input())
r=[]
w=[]
for i in range(n):
  if c[i]=='R':
    r.append(i)
  else:
    w.append(i)
w.reverse()
ans=0
for i in range(min(len(r),len(w))):
  if r[i]>w[i]:
    ans+=1
print(ans)
#! /usr/bin/env python3

# from math import gcd
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

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

L = Counter(c[:N//2])
R = Counter(c[N//2:])

if "W" not in c:
    print(0)
    exit()

ct = min(L["W"], R["R"])
if L["W"] < R["R"]:
    ct += R["R"] - L["W"]
    
A = Counter(c)
print(min(A["W"], A["R"], ct))
N=int(input())

c=list(input())

minimum=len(c)
W=0
R=c.count('R')

for i in range(0,len(c)):
    if c[i]=='W':
        W += 1
    else :
        R -= 1
    min_i=max(W,R)
    if min_i < minimum:
        minimum=min_i

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


if __name__ == '__main__':
  main()
from bisect import bisect_right as br

n = int(input())
c = list(input())
cFixed = [x for x in c]
cFixed.sort()
for i in range(n):
	if cFixed[i] == "R":
		lastR = i
ans = 0
for i in range(n):
	if c[i] != cFixed[i]:
		j = br(c,"R", lo = lastR + 1)-1
		#print(j,i,c[j],c[i],cFixed[i])
		c[i] = c[j]
		c[j] = "W"
		ans += 1


print(ans)
s = int(input())
n = input()
str_list = list(n)
w_cnt = str_list.count('W')
r_cnt = str_list.count('R')
if w_cnt == 0 or r_cnt == 0:
    print(0)
else:
    w_result = str_list[w_cnt:]
    r_result = str_list[:r_cnt]
    r = w_result.count('R')
    w = r_result.count('W')
    if w <= r:
        print(r)
    else:
        print(w)
n=int(input())
a=list(input())

# あかのインデックス
RR=[-1]
# しろのインデックス
WW=[]

for i in range(n):
    if a[i]=='R':
        RR.append(i)
    else:
        WW.append(i)
WW.append(float('inf'))

if a.count('R')==0 or a.count('R')==n:
    print(0)
    exit()

for i in range(len(RR)-1):
    if RR[-2-i]<WW[i+1]:
        print(i+1)
        exit()
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+1):
    if S[i] == "W":
      l += 1

print(min([wl, rl, l]))
N=int(input())
C=input()
from collections import Counter
count=Counter(C)
#print(count)
countR=count["R"]
countW=count["W"]
missR=0
missW=0
for i in range(N):
    now=C[i]
    if now=="W" and i<countW:
        missW+=1
    if now=="R" and i>=N-countR:
        missR+=1
# print(countR, countW)
X=min(missW, missR)
if X!=0:
    ans=min(missW, missR)+abs(missR-missW)
else:
    ans=0
print(ans)
n = int(input())
c = input()
sumr_ = 0
for _ in c:
    sumr_ += (_ == "R")
if sumr_ == len(c) or sumr_ == 0:
    print(0)
    quit()

sumr = sumr_
sumc = 0
minc = 10**8
for i in range(len(c)):
    if c[i] == "R":
        sumc += i
        sumr -= 1
        minc = min(sumr_, sumc + sumr)
print(minc)
n=int(input())
s=input()
if s.count('R')==0 or s.count('W')==0:
    print(0)
else:
    w=s.index('W')
    i=w
    while(i<len(s) and s[i]=='W'):
        i+=1
    a= i-w+1
    if i==len(s):
        print(0)
    else:
        b=s[i:].count('R')
        if a<b:
            b-=1
        print(min(s.count("W"),b))
n = int(input())
l = list(input())
num1 = l.count('R')
num2 = 0
i = 0
A = True
for i in range(num1):
    if l[i] != 'R':
        A = False
if num1 == 0 or A == True:
    print(0)
else:
    while l[i] != 'R':
        num2 += 1
        i += 1
    if num2 <= num1 - 1:
        print(num1 - 1)
    else:
        print(num1)
N = int(input())
C = list(input())
count = 0
for i in range(int(N/2)):
    if C[N-i-1] == 'R':
        for j in range(N-i-1):
            if C[j] == 'W':
                C[N-i-1] = 'W'
                C[j] = 'R'
                count += 1
                break
print(count)
N = int(input())
data = input()
intdata = []
ans = 0
for d in data:
  if d == "R":
    intdata.append(0)
  else:
    intdata.append(1)

sortdata = sorted(intdata)

if len(intdata) % 2 == 0:
  amari = 0
else:
  amari = 1

for i in range(int(len(intdata)/2) + amari):
  if intdata[i] != sortdata[i]:
    ans += 1

if len(intdata) % 2 == 1:
  print(ans-1)
else:
  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(math.ceil(N/2),N)):
    if c[i]=='R' :
        for u in (range(N)):
            if c[u]=='W':
                c[u]='y'
                c[i]='W'
                num+=1
                break
            
#print(c)
print(num)
N = int(input())
C = input()

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

if w <= r:
    print(C[0:w].count("W"))
else:
    print(C[w:len(C)].count("R"))
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')
else:
    count = C.count('W')
print(count)
N = int(input())
C = input()
W = C.count("W") 
R = N-W
counter = 0

if(W<R):
  wrong = C[:W-1].count("W")
  print(wrong)
else:
  wrong = C[W-1:].count("R")
  print(wrong)
n=int(input())
c=list(input())
lw_cnt=0
rw_cnt=0
rr_cnt=0
flg=-1
for i in range(n):
  if flg<0 and c[i]=='W':
    lw_cnt+=1
  elif flg<0 and c[i]=='R':
    flg=i
  elif flg>=0 and c[i]=='R':
    rr_cnt+=1
  else:
    rw_cnt=1
print(max(lw_cnt,rw_cnt*rr_cnt))
n = int(input())
a = input()
red = 0
for i in range(n):
  if a[i] == 'R':
    red += 1
ans = 0
for i in range(n-red):
  if a[i] == 'W':
    ans += 1
print(ans)
n = int(input())
c = input()

ans = 0
for v in c[: n // 2]:
    if v == "W":
        ans += 1
print(ans)
N=int(input())
C=input()
from collections import Counter
count=Counter(C)
#print(count)
countR=count["R"]
countW=count["W"]
missR=0
missW=0
for i in range(N):
    now=C[i]
    if now=="W" and i>=N-countW:
        missW+=1
    if now=="R" and i<countR:
        missR+=1
# print(countR, countW)
X=min(missW, missR)
if X!=0:
    ans=min(missW, missR)+abs(missR-missW)
else:
    ans=0
print(ans)
n = int(input())
s = [_ for _ in input()]

l, r = 0, n-1
if not('R' in s):
    print(0)
    exit()

if not('W' in s):
    print('0')
    exit()

ans = 0
while 1:
    while s[l] == 'W':
        l += 1

    while s[r] == 'R' and l < r:
        r -= 1

    ans += 1

    if l >= r:
        break

    l += 1
    r -= 1
print(ans)
N = int(input())
A =input()

if N % 2 == 0:
    k = N // 2
    B = A[0:k]
    #print(B)
    print(B.count("W"))

else:
    kk = N // 2
    B = A[0:kk+1]
    #print(B)
    print(B.count("W"))
import numpy as np

N=int(input())
C=np.array([x for x in input()])

if N%2==0:
  print(np.count_nonzero(C[:N//2]=='W'))
else:
  print(np.count_nonzero(C[:N//2+1]=='W'))
n = int(input())
c = input()

c = c.lstrip('R')
c = c.rstrip('W')
n = len(c)

rn = c.count('R')

if n == 0:
  print(0)
else:
  print(min(c[:rn].count('W'),c[n-rn:].count('R')))
N=int(input())
white=0
red=0
W=list(str(input()))
if "W" not in W or "R" not in W:
  print("0")
  exit()
for i in range(N//2):
  if W[i]=="W":
    white+=1
for i in range(N//2):
  if W[N-1-i]=="R":
    red+=1
if white>=red:
  print(red)
else:
  Z=white*2-red
  if (N/2)%1!=0:
    if W[N//2+1]=="W" and W[N//2+2]=="R":
      Z+=1
  print(Z)
n = int(input())
c = input()

# 1文字ずつのListに変換
list_c = ','.join(map(lambda x: '"{}"'.format(x), list(c)))

print(list_c)

all_change = 0

if list_c.count('W') < list_c.count('R') :
    all_change = list_c.count('W')
else :
    all_change = list_c.count('R')

print(all_change)
n=int(input())

s=list(input())

count_w = 0

w_list = []

r_list = []
for i in range(n):
    if s[i] == 'W':
        count_w += 1
        w_list.append(i)
    else:
        r_list.append(i)
w_list.reverse()

chage_count = 0
while len(w_list) > 0 and len(r_list) > 0 and r_list[-1] > w_list[-1]:
    r_list.pop()
    w_list.pop()
    chage_count += 1

if len(w_list) > 0 and len(r_list) == 0:
    chage_count += len(w_list)

print(min(chage_count, count_w))
import sys
N = int(input())
c = input()
n = int(N/2)
c_1 = c[:n]
print(c_1.count('W'))
n = int(input())
c = list(input())

r = 0
cnt = 0
for i in range(n):
    if c[i] == "R" :
        r += 1
    else :
        cnt = i
        break

print(c.count("R")-r)
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(N-i-1)):
            if c[u]=='W':
                c[u]='y'
                c[i]='W'
                num+=1
                break
            
#print(c)
print(num)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
c = [1 if _ == 'R' else 0 for _ in input()]
b = n-sum(c)

w=0
r=0

for i in range(n):
  if c[i] == 0 and i <= b:
    w+=1
  if c[i] == 1 and i > b:
    r+=1

print(max(w,r))
import sys
from itertools import groupby
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    c=list(input())[::-1]
    ans=0
    red=0
    for key, value in groupby(c):
        if key=='R':
            red=len(list(value))
        else:
            ans+=min(red,len(list(value)))
    print(ans)   


 
if __name__=='__main__':
    main()
n = int(input())
c = input()
count = 0
for i in range(n//2 + 1):
  if 'W' == c[i]:
    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+1):
        if c[i] == 'W':
            ans += 1
print(ans)
N = int(input())
C = input()

ans = 0
w = 0
r = 0
for i in range(N // 2):
    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())
a=input().split()
sum_red=0
for i in a:
  if i=="R":
    sum_red+=1
    
sum=0
for i in range(sum_red):
  if a[i]=="W":
    sum+=1
    
print(sum)
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('WR')
        wnum = a[rightmostW+2:].count('R')
        leftmostR = a.rfind('R')
        wnum2 = a[:leftmostR].count('W')
        r = min(wnum, wnum2)
        print(r)

if __name__ == '__main__':
    main()
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(ans)
n = int(input())
c = input()
r = 0
w = 0
l = 0
ans = 0
for i in range(n):
    if c[i] == "W":
        w += 1
    else:
        r += 1
        if i < n / 2:
            l += 1
if r == 0 or w == 0:
    print(0)
    exit()
elif w < r:
    ans += r - w
    r = w

ans += r - l
if ans <= w:
    print(ans)
else:
    print(w)
n = int(input())
c = list(input())

counter = 0
k = 0

i = 0
j = n-1

while i <= j:
	if c[i] == 'W' and c[j] == 'R':
		counter += 1
		i += 1
		j -= 1
	else:
		j -= 1
print(counter)
#D - Alter Altar /
N = int(input())
C =[]
C = list(map(str,input()))
total = 0

write_ko = len(list(filter(lambda x :x == 'W',C)))
red_ko   = N - write_ko
    
for i in range(N):
    for j in range(N-1,1,-1):
        if (C[i] == 'W') and (C[j] == 'R'):
            if (i < j):
                C[i] = 'G'
                C[j] = 'B'
                total += 1   
# 出力
print(total)
n = int(input())
c = input()
h1 = (n + 1) // 2
h2 = n // 2
ans1 = min(c[:h1].count('W'), c[h1:].count('R'))
ans2 = min(c[:h2].count('W'), c[h2:].count('R'))
print(min(ans1, ans2))
n=int(input())
c=list(input())
lw_cnt=0
rr_cnt=0
flg=-1
for i in range(n):
  if flg<0 and c[i]=='W':
    lw_cnt+=1
  elif flg<0 and c[i]=='R':
    flg=i
  elif flg>=0 and c[i]=='R':
    rr_cnt+=1
  else:
    rw_cnt=1
if lw_cnt==0 or rr_cnt==0:
  print(0)
else:
  print(max(lw_cnt,rr_cnt))
import collections
def main():
    N = int(input())
    S = list(input())
    if len(set(S))==1:
        print(0)
        return
    cnt = 0
    left = 0
    right = len(S)-1
    while left<right:
        if S[left] == 'W':
            cnt +=1
            left += 1
            right -=1
        while left<len(S) and S[left]=='R':
            left += 1
    print(cnt)
    return 0
if __name__ == "__main__":
    main()
import sys
input = sys.stdin.readline
 
n = int(input())
n2 = n//2
c = input()
 
if c.count("R") == n:
    print(0)
elif c.count("W") == n:
    print(0)
elif n%2 == 0:
    cnt = c.count("R", n2, n)
    print(cnt)
else:
    cnt = c.count("R", n2+1, n)
    print(cnt)
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
from collections import Counter

n = ii()
s = input()

d = Counter(s)
num = d['R']
ans = num
wcnt = 0
rcnt = 0
for i in s:
    if i == 'W':
        wcnt += 1
    else:
        if num - 1 > wcnt or wcnt == 0:
            ans -= 1
            num -= wcnt
            wcnt = 0
        else:
            break
print(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()
cnt = 0
while 'WR' in s:
    cnt += s.count('WR')
    s = s.replace('WR', '')
print(cnt)
k = int(input())
s = input()

most_left_r = 0
r_cnt_r = 0
r_cnt_w = 0
l_cnt_w = 0
res = 0
for i in range(len(s)):
    if s[i] == "R":
        most_left_r = i
        break
for j in range(most_left_r+1, len(s)):
    if s[j] == "R": r_cnt_r+=1
    else: r_cnt_w+=1

for k in range(0, most_left_r):
    if s[k] == "W": l_cnt_w += 1

res = max((min(r_cnt_r, r_cnt_w)), l_cnt_w)
print(res)
import math

N = int(input())
str = input()
A = list(str)

X = math.floor(N/2)
count = 0
for i in range(0,X+1):
    if A[i] == "R":
        count = count +1
    else:
        pass
print (X-count)
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 range(N):
    if c[i]=='R' :
        for u in reversed(range(math.ceil(N/2),N)):
            if c[u]=='W':
                c[u]='y'
                c[i]='W'
                num+=1
                break
            
#print(c)
print(num)
k = int(input())

L = list(input())

ans = 0
w = 0
r = 0
for i in range(1, k):
    if i <= k//2 and L[i] == "W":
        w += 1
    if i >= k//2 and L[i] == "R":
        r += 1

ans = (w + r)//2 + 1

if "W" not in L:
    ans = 0

if "R" not in L:
    ans = 0

print(ans)
n = int(input())
s = input()
w = s.count('W')
print(s[-w:].count('R'))
N = input()
li = input()
#print(li)
red = li.count("R")
white = li.count("W")

if red >= white:
  target = li[-1*white:]
  ans = white - target.count("W")
  print(ans)
  
else:
  print(red)
n = int(input())
cn = input()
cn = list(cn)

w_total = sum(1 for i, c in enumerate(cn) if cn[i] == 'W')
w = 0
mn = 10**9
for i, c in enumerate(cn, 1):
    if c == 'W':
        w += 1
    r = (len(cn) - i) - (w_total - w)
    m = max(r, w)
    mn = min(mn, m)

print(mn)
def change(S,index,color):
	lstS = list(S)
	lstS[index] = color
	S = ''.join(lstS)

	return S


if __name__ == '__main__':
	N = int(input())
	S = input()
	L = 0
	R = N-1
	count = 0
	if S.count('W') == 0 or S.count('R') == 0:
		R = -1
	while(L < R):
		while(S[L] == 'R'):
			L += 1
		while(S[R] == 'W'):
			R -= 1
		S = change(S,L,'R')
		S = change(S,R,'W')
		L += 1
		R -= 1
		count += 1

	print(count)
i=int(input())
s=list(input())
fw,fr=0,0
count=0
cw=0
cr=0
if s[0]=="W" and s[i-1]=="R":
    count+=1
    s[0]="R"
    s[i-1]="W"
if s[i-1]=="R":
    count+=1
    s[i-1]="W"
for j in range (i):
    if s[j]=="W" :
        fw=j
        cw+=1  
        break
print (s)
for j in range (fw+1,i):
    if s[j]=="R":
        count+=1
print(count)
# alter altar
length = int(input())
stone = input()
red = [0] * (length + 1)
white = [0] * (length + 1)
[red_num, white_num] = [0, 0]
for i in range(1, length + 1):
	if(stone[i-1] == "W"):
		white_num += 1
	if(stone[length-i] == "R"):
		red_num += 1
	white[i] = white_num
	red[length - i] = red_num
# print(white)
# print(red)
mini = 200000
for i in range(1, length+1):
	trial = max(white[i], red[i])
	mini = min(mini, trial)
print(mini)
n=int(input())
s=input()
l,r=0,n-1
ans=0
while l<r:
  cnt=0
  while r>=0 and s[r]=='W':r-=1
  while l<n and s[l]=='R':l+=1
  if l>=r:break
  while s[r]=='R':
    cnt+=1
    r-=1
  cm=cnt
  while cnt:
    if s[l]=='W':cnt-=1
    l+=1
    if l>=r:break
  if cnt>0:ans+=cnt
  else:ans+=abs(cm-cnt)
print(ans)
N = int(input())
c = list(input())
ans = 0
FLG = False
for i in range(N):
    if c[i] == "W":
        j = N - 1
        while c[j] == "W":
            j -= 1
            if j == i:
                FLG = True
                break
        if FLG:
            break
        ans += 1
        c[i], c[j] = c[j], c[i]

print(ans)
N = int(input())
C=list(input())
X=0
Y=0
print(C)
for i in range(N):
  if C[i]=='W':
    for ii in range(Y, N-i-Y):
      if C[N-1-ii]=='R':
        C[i]='R'
        C[N-1-ii]='W'
        X=X+1
        print(C)
        Y=ii
        break
  if i+Y==N-2:
    break
print(X)
N = int(input())
S = input()
count = 0
while True:
	if S.count('R') == 0:
		break
	if S[0] == 'R':
		S=S.lstrip('R')
	else:
		Rposfirst=S.find('R')
		Rposend = S.rfind('R')
		S = S[Rposfirst:Rposend]
		count += Rposfirst
print(count)
N = int(input())
C = input()

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

print(C[0:w].count("W"))
import math

def resolve():
    N=int(input())
    C=input()

    target = 'WR'
    index = -1
    cnt=0
    
    Rf=C[:N//2].count('R')
    Rr=C[N//2+1:].count('R')
    Wf=C[:N//2].count('W')
    Wr=C[N//2+1:].count('W')

    if(N%2==0):
        Centor=""
    else:
        Centor=C[N//2:N//2+1]

    cnt+=max(Wf,Rr)   

    if(C.count('R')==0 or C.count('W')==0):
        cnt=0

    print(cnt)
 
resolve()
N = int(input())
c = input()

if 'R' not in c:
    print(0)
    exit()

first_R = c.index('R')
num_R = c.count('R')

if first_R>num_R:
    print(num_R)
else:
    print(first_R+c[first_R:first_R+num_R].count('W'))
n = int(input())
k = input()
k2 = k[::-1]
i1 = 0
i2 = 0
cnt = 0
while i1 < n:
  if k[i1] == 'W':
    while i2 < n:
      if k2[i2] == 'R':
        k2 = k2[:i2] + 'W' + k2[i2+1:]
        cnt += 1
        break
      i2 += 1
  i1 += 1
  if i1 + i2 >= n:
    break
print(cnt)
N=int(input())
c=input()
if N%2==0:
    print(max(c[:N//2].count('W'),c[N//2:].count('R')))
else:
    print((max(c[:(N-1)//2].count('W'),c[(N-1)//2:].count('R'))))
N = int(input())
data = input()
intdata = []
ans = 0
for d in data:
  if d == "R":
    intdata.append(0)
  else:
    intdata.append(1)

sortdata = sorted(intdata)

if len(intdata) % 2 == 0:
  amari = 0
else:
  amari = 1

for i in range(int(len(intdata)/2)):
  if intdata[i] != sortdata[i]:
    ans += 1

print(ans)
n = int(input())
c = input()
p,q = 0,n-1
x = 0
while(p<q):
    while(c[p] == 'R' and p < n-1):
        p += 1
    while(c[q] == 'W' and q > 0):
        q -= 1
    if(p < n-1 and q > 0):
        p += 1
        q -= 1
        x += 1
    else:
        break
print(x)
N = int(input())
c = list(input())
pre = c[0:N//2]
suf = c[(N+1)//2:N]
mid = c[N//2] if N % 2 != 0 else 'F'
ans = 0

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

ans = min(pre_cnt,suf_cnt)

if mid == 'W' and suf_cnt-pre_cnt > 0:
    ans+=1
elif mid == 'R' and pre_cnt-suf_cnt > 0:
    ans+=1

print(ans)
n = int(input())
s = [_ for _ in input()]

l, r = 0, n-1
if not('R' in s):
    print(0)
    exit()

if not('W' in s):
    print('0')
    exit()

ans = 0
while 1:
    while s[l] == 'R':
        l += 1

    while s[r] == 'R' and l < r:
        r -= 1

    ans += 1

    if l >= r:
        break

    l += 1
    r -= 1
print(ans)
N=int(input())
c=input()
mid=N//2
if N%2==0:
  rl=c[mid:].count('R')
  wf=c[:mid].count('W')
else:
  rl=c[mid:].count('R')
  wf=c[:mid+1].count('W')
  
print(min(rl,wf))
import math

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

count_W = 0
for i in range(math.ceil(N/2)):
    if c[i] == 'W':
        count_W += 1
        
count_R = 0
for i in range(math.ceil(N/2)):
    if c[-1-i] == 'R':
        count_R += 1

print(min(count_R, count_W))
n = int(input())
c = list(input())
c2 = c[::-1]
cou = 0
for i in range(len(c)//2):
    if c2[i] == "R":
        cou += 1
for i in range(len(c)//2):
    if c[i] == "W":
        if c[i+1] == "R":
            cou += 1
print(cou)
N = int(input())
stones = input()
count_R = stones.count('R')

if N == count_R:
    answer = 0
elif N - count_R > count_R:
    answer = count_R
else:
    answer = count_R - 1

print(answer)