N=int(eval(input()))

d=eval(input())

r=d.count('R')

w=N-r

ans=r

leftr,leftw,rightr,rightw=0,0,r,N-r

for i in range(N):

  if d[i]=='R':

    leftr+=1

    rightr-=1

  else:

    leftw+=1

    rightw-=1

  if leftw==rightr:

    f=rightr

  elif leftw<rightr:

    f=rightr

  else:

    f=leftw

  ans=min(ans,f)

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

s=eval(input())

r=s.count('R')

cnt=0

for i in range(r):

  if s[i]=='W':

    cnt+=1

print(cnt)
N = int(eval(input()))
d = eval(input())
r = d.count("R")
w = N - r
ans = r
leftr, leftw, rightr, rightw = 0, 0, r, N - r
for i in range(N):
    if d[i] == "R":
        leftr += 1
        rightr -= 1
    else:
        leftw += 1
        rightw -= 1
    if leftw == rightr:
        f = rightr
    elif leftw < rightr:
        f = rightr
    else:
        f = leftw
    ans = min(ans, f)
print(ans)

N = int(eval(input()))
s = eval(input())
r = s.count("R")
cnt = 0
for i in range(r):
    if s[i] == "W":
        cnt += 1
print(cnt)

-d = eval(input()) -r = d.count("R") -w = N - r -ans = r -leftr, leftw, rightr, rightw = 0, 0, r, N - r -for i in range(N): -    if d[i] == "R": -        leftr += 1 -        rightr -= 1 -    else: -        leftw += 1 -        rightw -= 1 -    if leftw == rightr: -        f = rightr -    elif leftw < rightr: -        f = rightr -    else: -        f = leftw -    ans = min(ans, f) -print(ans) +s = eval(input()) +r = s.count("R") +cnt = 0 +for i in range(r): +    if s[i] == "W": +        cnt += 1 +print(cnt)