n=int(eval(input()))

a=list(eval(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()

if a.count('W')==1 or a.count('R')==1:

    print((1))

    exit()



for i in range(len(RR)-1):

    if RR[-2-i]<WW[i+1]:

        ans=i+1

        break



# 白くするコスト

wc = [0]

# 赤くするコスト

rc = [0]



import itertools



a = ['R'] + a



if a[-1] == 'R':

    a.append('W')

else:

    a.append('R')



cntr = 0

cntw = 0

flag1 = True

for i in range(n + 2):

    if a[i] == 'W':

        cntr += 1

        if flag1:

            flag1 = False

        else:

            if cntw != 0:

                wc.append(cntw)

                cntw = 0

    else:

        if flag1:



            continue

        else:

            cntw += 1

            if cntr != 0:

                rc.append(cntr)

                cntr = 0



wc = list(itertools.accumulate(wc))

rc = list(itertools.accumulate(rc))





for i in range(len(wc)):

    ans = min(ans, rc[i] + wc[-1] - wc[i])

print(ans)

n=int(eval(input()))

a=list(eval(input()))



# あかのインデックス

RR=[]



for i in range(n):

    if a[i]=='R':

        RR.append(i)





v=a.count('R')

ans=v

for i in range(len(RR)):

    if RR[i]+1<=v:

        ans-=1

print(ans)
n = int(eval(input()))
a = list(eval(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()
if a.count("W") == 1 or a.count("R") == 1:
    print((1))
    exit()
for i in range(len(RR) - 1):
    if RR[-2 - i] < WW[i + 1]:
        ans = i + 1
        break
# 白くするコスト
wc = [0]
# 赤くするコスト
rc = [0]
import itertools

a = ["R"] + a
if a[-1] == "R":
    a.append("W")
else:
    a.append("R")
cntr = 0
cntw = 0
flag1 = True
for i in range(n + 2):
    if a[i] == "W":
        cntr += 1
        if flag1:
            flag1 = False
        else:
            if cntw != 0:
                wc.append(cntw)
                cntw = 0
    else:
        if flag1:
            continue
        else:
            cntw += 1
            if cntr != 0:
                rc.append(cntr)
                cntr = 0
wc = list(itertools.accumulate(wc))
rc = list(itertools.accumulate(rc))
for i in range(len(wc)):
    ans = min(ans, rc[i] + wc[-1] - wc[i])
print(ans)

n = int(eval(input()))
a = list(eval(input()))
# あかのインデックス
RR = []
for i in range(n):
    if a[i] == "R":
        RR.append(i)
v = a.count("R")
ans = v
for i in range(len(RR)):
    if RR[i] + 1 <= v:
        ans -= 1
print(ans)

-RR = [-1] -# しろのインデックス -WW = [] +RR = [] -    else: -        WW.append(i) -WW.append(float("inf")) -if a.count("R") == 0 or a.count("R") == n: -    print((0)) -    exit() -if a.count("W") == 1 or a.count("R") == 1: -    print((1)) -    exit() -for i in range(len(RR) - 1): -    if RR[-2 - i] < WW[i + 1]: -        ans = i + 1 -        break -# 白くするコスト -wc = [0] -# 赤くするコスト -rc = [0] -import itertools - -a = ["R"] + a -if a[-1] == "R": -    a.append("W") -else: -    a.append("R") -cntr = 0 -cntw = 0 -flag1 = True -for i in range(n + 2): -    if a[i] == "W": -        cntr += 1 -        if flag1: -            flag1 = False -        else: -            if cntw != 0: -                wc.append(cntw) -                cntw = 0 -    else: -        if flag1: -            continue -        else: -            cntw += 1 -            if cntr != 0: -                rc.append(cntr) -                cntr = 0 -wc = list(itertools.accumulate(wc)) -rc = list(itertools.accumulate(rc)) -for i in range(len(wc)): -    ans = min(ans, rc[i] + wc[-1] - wc[i]) +v = a.count("R") +ans = v +for i in range(len(RR)): +    if RR[i] + 1 <= v: +        ans -= 1