An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; R stands for red and W stands for white.
You can do the following two kinds of operations any number of times in any order:
 - Choose two stones (not necessarily adjacent) and swap them.
 - Choose one stone and change its color (from red to white and vice versa).
According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

-----Constraints-----
 - 2 \leq N \leq 200000
 - c_i is R or W.

-----Input-----
Input is given from Standard Input in the following format:
N
c_{1}c_{2}...c_{N}

-----Output-----
Print an integer representing the minimum number of operations needed.

-----Sample Input-----
4
WWRR

-----Sample Output-----
2

For example, the two operations below will achieve the objective.
 - Swap the 1-st and 3-rd stones from the left, resulting in RWWR.
 - Change the color of the 4-th stone from the left, resulting in RWWW.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
c = input()

w = 0
r = c.count('R')
i = 0
ans = max(w, r)
while i <= n - 1:
    if c[i] == 'W':
        w += 1
    else:
        r -= 1
    ans = min(ans, max(w, r))
    i += 1
print(ans)

from collections import Counter
N = int(input())
s = input()
c = Counter(s)
w, r = 0, c['R']
ans = max(w, r)
for i in range(N):
    if s[i] == 'W': w += 1
    else: r -= 1 
    ans = min(ans, max(w, r))

print(ans)

input()
problem = input()
stones = []
rs = []
# 赤が1,白が0
W=0
R=0
for s in problem:
    if s == "R":
        stones.append(1)
        R+=1
    else:
        stones.append(0)
rs.append(max(W, R))
for i in range(len(stones)):
    if stones[i] == 0:
        W+=1
    else :
        R-=1
    rs.append(max(W, R))
print(min(rs))

N=int(input())
C=list(input())
rednum=C.count('R')
rednumleft=0
for i in range(rednum):
    if C[i]=='R':
        rednumleft+=1
print(rednum-rednumleft)

def solve(string):
    _, c = string.split()
    r = c.count("R")
    return str(c[:r].count("W"))


def __starting_point():
    import sys
    print((solve(sys.stdin.read().strip())))

__starting_point()

import heapq

def main():
    N = int(input())
    C = list(input())
    R = []
    W = []
    for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
    if len(R) == 0 or len(W) == 0:
        print((0))
        return
    heapq.heapify(R)
    heapq.heapify(W)
    ans = 0
    while True:
        max_r = -1 * heapq.heappop(R)
        min_w = heapq.heappop(W)
        if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
    print(ans)


def __starting_point():
    main()

__starting_point()

from collections import Counter


N = int(input())
c = input()
cntr = Counter(c)

ans = 0
for c, r in zip(c, "R" * cntr["R"]):
    if c != r:
        ans += 1
print(ans)


n=int(input())
c=str(input())
a=c.count("R")
b=c[:a:].count("R")
print(a-b)

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

r = C.count("R")
print(C[:r].count("W"))

n = int(input())
c = list(input())
rcnt = 0
allrcnt = 0
for i in range(len(c)):
    if c[i]=='R':
        allrcnt += 1
for i in range(len(c)):
    if i+1<=allrcnt and c[i]=='R':
        rcnt += 1

ans = allrcnt-rcnt

print(ans)

n = int(input())
c = list(input())
w = 0
r = c.count("R")
ans = r
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)


n = int(input())
clist = input()

wcount=clist.count('W')
rcount=n-wcount
aclist='R'*rcount+'W'*wcount

wrcount = 0
rwcount = 0

for i in range(n):
  if clist[i] == aclist[i]:
    continue
  else:
    if clist[i] == 'W':
      wrcount += 1
    else:
      rwcount += 1

print((max(wrcount,rwcount)))


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

f = 0
b = N - 1
ans = 0

while True:
    while  f <= N -1 and C[f] == "R":
        f += 1
    while b >= 0 and C[b] == "W":
        b -= 1
    if f > b:
        print(ans)
        break
    ans += 1
    f += 1
    b -= 1

n = int(input())
c = list(input())
c_goal = list(sorted(c))

count = 0

for x in range(n):
  if c[x] != c_goal[x]:
    count += 1
    
count = count // 2
print(count)


import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n = int(input())
    C = input()
    C_cunt = Counter(C)
    cunt_r = C_cunt['R']
    ans = 0
    for i in range(cunt_r):
        if C[i] == 'W':
            ans += 1
    print(ans)

def __starting_point():
    main()
__starting_point()

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

a, b = 0, 0
for i in range(n):
    if C[i] == "R":
        a += 1
    ans = max(a, b)

for i in range(n):
    if C[i] == "R":
        a -= 1
    else:
        b += 1
    tmp = max(a, b)
    ans = min(ans, tmp)

print(ans)

import sys
import re
import queue
import collections
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N = i_input()
	C = s_input()
	c = []
	for i in range(0,N):
		c.append(C[i])

	answer = 40000000

	tmp = 0
	for i in range(0,N):
		if(c[i]=="R"):
			tmp += 1

	answer = min(answer,tmp)

	tmp = 0
	for i in range(0,N):
		if(c[i]=="W"):
			tmp += 1

	answer = min(answer,tmp)

	whiteCount = 0
	redCount = 0
	for i in range(0,N):
		if(c[i]=="R"):
			redCount += 1
	whiteCount = N - redCount

	
	leftWhiteCount = 0
	rightRedCount = redCount
	for i in range(0,N):
		if(c[i] == "W"):
			leftWhiteCount += 1
		else:
			rightRedCount += -1
		answer = min(answer,max(leftWhiteCount,rightRedCount))

	print(answer)

	return

def __starting_point():
	main()
__starting_point()

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

n=int(input())
c=list(input())
cnt=0
allcnt=c.count("R")
for i in range(allcnt):
  if c[i]=="R":
    cnt+=1
print(allcnt-cnt)

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 = list(input())
Rn = c.count("R") # 区切りの右側に存在するRの数
Wn = 0 # 区切りの左側に存在するWの数
ans = N
for i in range(N+1):
    if i == 0:
        ans = Rn
    else:
        if c[i-1] == "R":
            Rn -= 1
        else:
            Wn += 1
        ans = min(ans, min(Rn, Wn) + abs(Rn - Wn))
print(ans)

n, s = input(), input()
print(s[:s.count("R")].count("W"))

n=int(input())
S=input()
c=S.count("R")
s=S[:c].count("R")
print(c-s)

n = int(input())
C = input()
R = C.count("R")
print((C[: R].count("W")))


def solve1(n: int, c: str) -> int:
    ans = 0
    r, w = 0, 0

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

    s_pivot = c[:r] + "|" + c[r:]
    s_check = " " * r + "|"

    for i in range(r, n):
        if c[i] == "R":
            ans += 1
            s_check += "X"
        else:
            s_check += " "

    #print(s_pivot, s_check, sep="\n")
    return ans


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

print((solve1(n, c)))


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

a=c.count('R')

cnt=0
for i in range(a):
    if c[i]=='W':
        cnt+=1
print(cnt)

n = int(input())
s = input()
res = 0
tem = s.find('WR')
if tem == -1:
    print(res)
else:
    i, j = 0, len(s)-1
    while i<j:
        while i < j and s[i] != 'W': i+=1
        while i < j and s[j] != 'R':j -= 1
        if s[i] == 'W' and s[j] == 'R':
            res += 1
            i += 1
            j -= 1
    print(res)



number = int(input())
date = input()
date = list(date)
cnt =0
cnt2 =0

for i in range(number):
  if date[i] =="R":
    cnt +=1

for s in range(cnt):
  if date[s] =="W":
    cnt2 +=1
print(cnt2)

n = int(input())
c = list(input())
hrcnt = 0
rcnt = 0
for i in range(len(c)):
    if c[i]=='R':
        rcnt += 1
for i in range(len(c)):
    if i+1<=rcnt and c[i]=='R':
        hrcnt += 1

wcnt = len(c)-rcnt
if rcnt==len(c) or rcnt==0:
    ans = 0
else:
    ans = rcnt-hrcnt

print(ans)

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

a = c.count("R")
b = c[:a].count("W")
print(b)



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

r = s.count('R')

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

print(ans)

import math
import collections
import itertools
import copy

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return


def resolve():

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

    l=0
    r=N-1
    lfound=False
    rfound=False

    cnt=0
    while True:
        if(C[l]=="W"):
            lfound=True
        else:
            l+=1

        if(C[r]=="R"):
            rfound=True
        else:
            r-=1

        if(rfound and lfound):
            cnt+=1
            l+=1
            r-=1
            rfound=False
            lfound=False
        if(l>=r):
            break

    print(cnt)


resolve()


# 初期入力
from bisect import bisect_left
import sys
#input = sys.stdin.readline  #文字列では使わない
N = int(input())
c =input().strip()
ans =0
w =[i for i, x in enumerate(c) if x == 'W']
r =[i for i, x in enumerate(c) if x == 'R']
w_num =len(w) #全体でWの数
r_num =len(r) #全体でRの数

ans =bisect_left(r,r_num)
print(r_num -ans)

N = int(input())
str = input()

r_sum = 0
for i in range(N):
    if str[i] == "R":
        r_sum += 1
r_sum2 = 0
for i in range(r_sum):
    if str[i] == "R":
        r_sum2 += 1

print((r_sum - r_sum2))


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

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

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

N = int(input())
c = list(input())
w = 0
r = N-1
ans = 0
while w < r:
    for i in range(w,r):
        if c[i] == "W":
            c[i] = "R"
            w = i
            break
    else:
        break
    for j in range(r,w,-1):
        if c[j] == "R":
            c[j] = "W"
            r = j
            break
    else:
        break
    ans += 1
print(ans)

N = int(input())
s = input()

R = 0
for i in range(N):
  if s[i] == "R":
    R += 1
W = 0
ans = R

for i in range(N):
  if s[i] == "R":
    R -= 1
  else:
    W += 1
  ans = min(ans, max(W, R))
  
print(ans)

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
s = input()
C = Counter(s)
w,r = 0,0
for k,v in list(C.items()):
    if k == 'W':
        w += v
    else:
        r += v
p = 'R' * r + 'W' * w
ans = 0
for i in range(n):
    if p[i] == s[i]:
        pass
    else:
        ans += 1
print((ans//2))


def main():
    n = int(input())
    C = input()

    rc = C.count('R')
    rhc = C[:rc].count('R')
    print((rc - rhc))


def __starting_point():
    main()

__starting_point()

n = int(input())
c = input()
x = 0
for i in range(n):
    if c[i] == "R":
        x += 1

y = 0
if x != 0:
    for j in range(x):
        if c[j] == "W":
            y += 1

print(y)

N = int(input())
S = input()
Answer = 0
White = 0
Red = S.count('R')
for j in range(len(S)):
    i = S[j]
    if i == 'W':
        White += 1
    elif i == 'R' and White >0 and j+1 > Red:
        Answer += 1
        White -= 1
print(Answer)

# import sys
# input = sys.stdin.readline
import collections

def main():
    n = int(input())
    s = input()
    a_list = []
    for i in range(n):
        if s[i] == "W":
            a_list.append(0)
        else:
            a_list.append(1)
    r_count = sum(a_list)
    print((r_count - sum(a_list[0:r_count])))


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


def input_list_str():
    return list(map(str, input().split()))


def __starting_point():
    main()

__starting_point()

N = int(input())
C = list(input())
count = list()
W = 0
R = 0

for i in C:
    if i == "R":
        R += 1

if R == 0:
    count.append(0)

for i in C:

    if i == "W":
        W += 1
    else:
        R -= 1

    if W <= R:
        count.append(R)
    else:
        count.append(W)

print(min(count))

a = int(input())
s = input()
ans = a
w_to_r =0
r_to_w =s.count('R')
ans = min(ans,max(w_to_r,r_to_w))
for i in range(a):
    if s[i] =='W':
        w_to_r +=1
    else:
        r_to_w -=1
    ans = min(ans,max(w_to_r,r_to_w))
print(ans)       

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

count_red = 0
flag_red = []

for i in c:
	if i == 'W':
		flag_red.append(0)
	else:
		flag_red.append(1)
		count_red += 1

if count_red == 0:
	ans = 0
else:
	ans = count_red - sum(flag_red[0:count_red])

print(ans)

import copy


def swap(data, i1, i2):
    # i1 と i2とスワップ
    tmp = data[i1]
    tmp2 = data[i2]
    data[i2] = tmp
    data[i1] = tmp2
    return data


def check_finish(data):
    out = True
    for i in range(len(data)-1):
        if data[i] == 'W' and data[i + 1] == 'R':
            out = False
            return out
    return out


def __starting_point():
    n = int(input())
    c = list(input())
    # print(c)
    if 'R' not in c:
        # print("'R' not in")
        print((0))
    elif 'W' not in c:
        # print("'W' not in")
        print((0))
    else:
        w_count = c.count('W')
        r_count = c.count('R')

        same_r_count = 0
        for i in range(r_count):
            if c[i] == 'R':
                same_r_count += 1

        # print(r_count, same_r_count)
        A = r_count - same_r_count
        print(A)

__starting_point()

import sys

N = int(input())
S = list(input())

c = min(S.count('R'), S.count('W'))
r = 0
count = 0
for l in range(N-c):
    if S[l] == 'W':
        for i in range(r, len(S)-c):
            if S[-(i+1)] == 'R':
                S[-(i + 1)] = 'W'
                S[l] = 'R'
                count += 1
                break
            r = i

print(count)

n=int(input())
s = str(input())
r = 0
w = 0
d = 0
for i in range(n):
    if (s[i] == 'R'):
        r += 1
    else:
        w += 1
sd = sorted(s)
for i in range(n):
    if (s[i] != sd[i]):
        d += 1

if (w == 0 or r == 0):
    print((0))
else:
    print((min(r, w, int(d/2))))



def solve(string):
    n, c = string.split()
    n, c = int(n), list(c)
    wi, ri = 0, n - 1
    while wi < n and c[wi] == "R":
        wi += 1
    while ri >= 0 and c[ri] == "W":
        ri -= 1
    ans = 0
    while wi < n and ri >= 0 and wi < ri:
        c[wi], c[ri], ans = c[ri], c[wi], ans + 1
        wi, ri = wi + 1, ri - 1
        while wi < n and c[wi] == "R":
            wi += 1
        while ri >= 0 and c[ri] == "W":
            ri -= 1
    return str(ans)


def __starting_point():
    import sys
    print((solve(sys.stdin.read().strip())))

__starting_point()

n = int(input())
s = list(input().rstrip())

left_cur = 0
right_cur = n - 1
ans = 0
flag = False
while(left_cur < right_cur and left_cur < n - 1 and right_cur > 0):
    while(s[left_cur] == 'R'):
        left_cur += 1
        if (left_cur == n - 1):
            flag = True
            break
    while(s[right_cur] == 'W'):
        right_cur -= 1
        if (right_cur == 0):
            flag = True
            break
    if(left_cur > right_cur):
        flag = True
    if(flag):
        break
    ans += 1
    left_cur += 1
    right_cur -= 1

print(ans)


n=int(input())
C = list(input())
ans = 0
N = n-1
for l in range(n):
    if C[l] == "W":
        for r in range(N,0,-1):
            if r<=l:
                print(ans)
                return
            if C[r] == "R":
                #print(C)
                C[l] = "R"
                C[r] = "W"
                #print(C)
                #print("-----------------")
                ans += 1
                N = r-1
                break
print(ans)

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = inf

lr = 0
lw = 0
r = C.count("R")
w = C.count("W")
if r == 0 or w == 0:
    res = 0
else:
    for i in range(n):
        tmp = max(lw, r - lr)
        res = min(res, tmp)
        if C[i] == "R":
            lr += 1
        else:
            lw += 1

print(res)


N=int(input())
c=input()
R=c.count('R')
RR=c[0:R].count('R')
print(min(R-RR,R,N-R))

import math
N = int(input())
C = str(input())

C = C.replace('W', '1').replace('R', '0')
C = list(C)
sort_C = sorted(C)

cnt = 0

for i in range(N):
    if C[i] != sort_C[i]:
        cnt += 1

print(math.ceil(cnt/2))

import sys

N = int(input())
S = input()

print(S[S.count('R'):len(S)].count('R'))

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

Rn = C.count('R')
print(C[:Rn].count('W'))

import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
c = list(rs())
ans = 0
s = 0
e = N - 1
while True:
    while c[s] == 'R' and s < e:
        s += 1
    while c[e] == 'W' and s < e:
        e -= 1
    if s == e:
        break
    else:
        c[s] = 'R'
        c[e] = 'W'
        ans += 1
print(ans)

def __starting_point():
    n = int(input())
    s = list(input())
    
    #完成品の並びにする
    ss = sorted(s)
    
    cnt = 0
    #切り替わりの地点まで＝Wが見つかる部分まで
    if "W" in s:
        sind = ss.index("W")

        #sindまでに含まれるWの数？
        cnt = 0
        for i in range(sind):
            if s[i] == "W":
                cnt += 1

    print(cnt)

__starting_point()

N = int(input())
s = str(input())

a = 0
b = 0

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


n = int(input())
cl = input()

if cl[:cl.count('R')].count('W') != 0:
    print(min(cl[:cl.count('R')].count('W'), cl.count('R')))
else:
    print(0)

N=int(input())
S=input()
ls=[0 for _ in range(N)]
for i in range(N):
  if S[i]=='W':
    ls[i]=1
ans=0
i=0
j=N-1
while True:
  if ls[i]==1 and ls[j]==0:
    ls[i]=0
    ls[j]=1
    i+=1
    j-=1
    ans+=1
  elif ls[i]==0 and ls[j]==0:
    i+=1
  elif ls[i]==1 and ls[j]==1:
    j-=1
  else:
    i+=1
    j-=1
  if i>=j:
    break
print(ans)

n = int(input())
mozi = input()
a_list = []
for i in range(n):
    if mozi[i] == 'W':
        a_list.append(0)
    else:
        a_list.append(1)
r_count = sum(a_list)
print(r_count - sum(a_list[0:r_count]))

N=int(input())
S=input()
i=0
j=N-1
ans=0
while True:
    while S[j]=='W':
        j-=1
        if j<0:
            break
    while S[i]=='R':
        i+=1
        if i>=N:
            break
    if j<i:
        break
    ans+=1
    i+=1
    j-=1
    if j<i:
        break
print(ans)


n = int(input())
c = str(input())
cc = c[:c.count("R")]
print(cc.count("W"))

n=int(input())
s=input()
w=s.count('W')
r=s.count('R')

ans=10**9
if w==0 or r==0:
  print(0)
  return

left_white, right_red=0,r
for i in range(n):
  if s[i]=='W':
    left_white+=1
  else:
    right_red-=1
  ans=min(ans,max(left_white,right_red))
  
print(ans)

def main():
    n = int(input())
    s = input()
    rcount = s.count('R')
    diff = s[0:rcount].count("W")

    print(diff)




def __starting_point():
    main()
__starting_point()

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

r_cnt=c.count('R')
w_cnt=c.count('W')

last_c='R'*r_cnt+'W'*w_cnt

num=0
for i in range(n):
  if c[i]!=last_c[i]:
    num+=1

print((num+2-1)//2)

n = int(input())
wr = input()
R_cnt = wr.count('R')
ans = wr.count('W',0,R_cnt)
print(ans)

# RRR..WWW..を目指す
n = int(input())
s = list(input())
w_count, r_count = s.count("W"), s.count("R")
t = list("R" * r_count + "W" * w_count)

ans = 0
for i in range(n):
    if s[i] != t[i]:
        ans += 1
print(min(w_count, r_count, ans // 2))

N = int(input())
c = input()
w = 0
r = c.count('R')
Cand ={r}
for i in range(N):
    if c[i] == 'R':
        r -= 1
    else:
        w += 1
    Cand.add(max(w,r))
print(min(Cand))

def solve1(n: int, c: str) -> int:
    ans = 0
    r, w = 0, 0
 
    for i in range(n):
        if c[i] == "R":
            r += 1
        else:
            w += 1
 
    s_pivot = c[:r] + "|" + c[r:]
    s_check = " " * r + "|"
 
    for i in range(r, n):
        if c[i] == "R":
            ans += 1
            s_check += "X"
        else:
            s_check += " "
 
    #print(s_pivot, s_check, sep="\n")
    return ans
 
 
n = int(input())
c = input()
 
print(solve1(n, c))

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

if "R" not in C:
    print(0)
    return

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)

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

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

R_r = c.count("R")
W_l = 0
ans = N
for i in range(N+1):
  t = max(R_r,W_l)
  ans = min(ans, t)
  if R_r == 0:
    break
  if c[i] == "R":
    R_r -= 1
  else:
    W_l += 1

print(ans)

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

n=0
c=0
for i in range(N)[::-1]:
    if C[i]=="R":
        while n<i:
            if C[n]=="W":
                c+=1
                n+=1
                break
            n+=1
print(c)


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

i = 0
j = N - 1
count = 0

while t:
	if c[i] == "R":
		i += 1
	elif c[j] == "W":
		j -= 1
	elif c[i] == "W" and c[j] == "R":
		c[i] = "R"
		c[j] = "W"
		count += 1	
	if i >= j:
		t = False
		break
print(count)


n = int(input())
li_c = input()
r_index = [i for i,x in enumerate(li_c) if x=="R"]
w_index = [i for i,x in enumerate(li_c) if x=="W"]
r_num = len(r_index)
w_num = len(w_index)

R = r_num
W = 0
ans = max(R, W)
for i in range(n):
    if li_c[i]=="R":
        R -= 1
    else:
        W += 1
    ans = min(ans, max(R, W))
print(ans)

import sys
from collections import Counter

input = sys.stdin.readline
N = int(input())
C = list(input().strip())

counter = Counter(C)
if len(counter) == 1:
    print(0)
else:
    red_n = counter["R"]
    ans = 0
    for i in range(N):
        if red_n <= i:
            break
        if C[i] == "W":
            ans += 1
    print(ans)

import collections
n = int(input())
wr = list(input())

cc = collections.Counter(wr)
r = cc['R']

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

print(ans)

n = int(input())
x = list(input())

sx = len(set(x))
if sx == 1:
    print(0)
    return

cnt_r = x.count("R")
cnt = 0
for i in range(cnt_r):
    if x[i] == "W":
        cnt += 1
print(cnt)

n = int(input())
c = input()
x = c.count("R")
c2 = c[:x]
ans = c2.count("W")
print(ans)


n = int(input())
# cs = ['W' for i in range(200000)]
cs = input()

w_count = 0
for c in cs:
    if c == 'W':
        w_count += 1

if w_count == 0:
    print((0))
    return

rest = cs[-w_count:]

answer = 0
for c in rest:
    if c == 'R':
        answer += 1
print(answer)


n = int(input())
ccc = input()
cnt_r = ccc.count('R')
ans = 0
for i in range(cnt_r):
    if ccc[i] == 'W':
        ans += 1
print(ans)

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


rw=C.count('R')
wr=0
ans=rw

for i in range(N):
    if C[i]=='R':
        rw-=1
    else:
        wr+=1
    ans=min(ans,max(rw,wr))
print(ans)


# 初期入力
from bisect import bisect_left
import sys
#input = sys.stdin.readline  #文字列では使わない
N = int(input())
c =input().strip()
ans =0
r =[i for i, x in enumerate(c) if x == 'R'] #全体の中でRのIndex
r_num =len(r) #全体でRの数

ans =bisect_left(r,r_num) #呪われないためのRとWの境界
print(r_num -ans) #境界より右側のRの数

# D
from collections import Counter
n = int(input())
c = list(input())
d = Counter(c)
# print(d)
# print(d["R"])
e=Counter(c[:d["R"]])
# print(e["R"])
print(d["R"]-e["R"])

import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

n = readInt()
text = readStringList()
import collections
c  = collections.Counter(text)
if c['W'] == 0:
    print("0")
    return
i,j,count = 0,len(text)-1,0

while i <= j and i < len(text):
    if text[i] == 'W':
        while text[j] != 'R' and j > 0:
            j -= 1
        if i <= j and j > 0:
            text[i],text[j] = text[j],text[i]
            count += 1
    i += 1
print(count)



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

r = c.count("R")
ans = 0
for i in range(r):
  if c[i] == "W": ans += 1
print(ans)

import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    n = int(input())
    c = list(input())
    l, r = 0, len(c) - 1

    result = 0
    while r - l > 0:
        if c[l] == 'W' and c[r] == 'R':
            c[l], c[r] = c[r], c[l]
            result += 1
        if c[r] == 'W':
            r -= 1
        if c[l] == "R":
            l += 1
        # print(c)
    print(result)


def __starting_point():
    main()

__starting_point()

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

R_count=C.count('R')
if R_count==0:
  print((0))
  return

C_count=C[:R_count].count('R')
print((R_count-C_count))


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

# 入れ替えても色を変えてもコストは変わらない
# 最も左にあるWと最も右にあるRを入れ替え、RRR・・・WWW・・・を目指す
# 初期局面と最終局面を比較すると、入れ替えるべき石の総数が分かる

r_cnt = c.count('R')
print(c[:r_cnt].count('W'))

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

# それぞれの色の数をカウント
w = c.count("W")
r = c.count("R")

ans = 0
for i in range(r): #　赤の数分文字列を確認する
  if c[i] == "W": ans += 1 # カウント
print(ans)

import bisect

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

R_count = bisect.bisect_right(c_sorted, 'R')
ans = 0
for i in range(R_count):
    if c[i] != 'R':
        ans += 1
print(ans)

n = int(input())
c = str(input())
ans = 0

r_cnt = c.count('R')

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

print(ans)


#https://blacktanktop.hatenablog.com/entry/2020/08/05/073335 をまねした
n = int(input())
C = input()
r_all = C.count('R')
# CをRWRWRWRとした時に、
# どの状態にするのが最小手数かがわからないので全パターンである以下の状態における最小手数を計算する。
# ある場所を境に右側をW左側をRとするイメージ。
# |RWRWRWR→WWWWWWW
# R|WRWRWR→RWWWWWW
# RW|RWRWR→RRWWWWW
# .......
# RWRWRW|R→RRRRRRW
# RWRWRWR|→RRRRRRR
# 最小手数をリストに入れておく。パターンはn+1
move = [0] * (n+1)
# 実際の並びにおいて、|の左のW右のRの数をw, rとする
# 初期値はw=0, r=CのうちRの数
w = 0
r = r_all
# moveの初期値はすべてWを目指すので
move[0] = max(0, r_all)
# forで１文字ずつ見ていくのは区切りを一つずつずらしているイメージ
# Cの文字をみてWならwを1増やしてRならrを1減らす
# （区切りの左のWの数がwで右のRの数がrなので）
for idx, c in enumerate(C):
    if c == 'W':
        w += 1
    else:
        r -= 1 
    move[idx+1] = max(w, r)
ans = min(move)
print(ans) 

N = int(input())
C = input()
R = C.count("R")
ans = 0

for r in range(R):
  if C[r]=="W":
    ans+=1

print(ans)

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

r_cnt = c.count("R")

print(r_cnt - c[:r_cnt].count("R"))

def main():
    n = int(input())
    c = str(input())

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

    w_count_ano = 0
    for i in range(w_count):
        if c[- 1 - i] == 'W':
            w_count_ano += 1

    count = w_count - w_count_ano
    print(count)


def __starting_point():
    main()
__starting_point()

import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
def main():
    n = int(input())
    rc = tuple(input())
    rc2 = [c == 'W' for c in rc]
    r1 = sum(rc2) # 白をすべて赤にした場合
    r2 = n - r1  # 赤をすべて白にした場合。
    r3 = sum(rc2[:r2]) # 赤を左につめるのに邪魔になる白の数
    print((min(r1, r2, r3)))

def __starting_point():
    main()

__starting_point()