N = int(eval(input()))

c = eval(input())



right = N - 1

left = 0

ans = 0

flag = False



while True:

  if c[right]=='W':

    if (right>=1)and(right>left+1):

      right -= 1

      continue

    else:

      break

    

  else:

    while True:

      if c[left]=='R':

        if (left<N)and(left<right-1):

          left += 1

          continue

        else:

          flag = True

          break

        

      else:

        ans += 1

        left += 1

        right -= 1

        break

    if flag:

      break

      

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

c = eval(input())

W = 0

R = 0



for x in c:

  if x=='R':

    R += 1



ans = R

for x in c:

  if x=='W':

    W += 1

  else:

    R -= 1

    

  ans = min(ans,max(R,W))

  

print(ans)
N = int(eval(input()))
c = eval(input())
right = N - 1
left = 0
ans = 0
flag = False
while True:
    if c[right] == "W":
        if (right >= 1) and (right > left + 1):
            right -= 1
            continue
        else:
            break
    else:
        while True:
            if c[left] == "R":
                if (left < N) and (left < right - 1):
                    left += 1
                    continue
                else:
                    flag = True
                    break
            else:
                ans += 1
                left += 1
                right -= 1
                break
        if flag:
            break
print(ans)

N = int(eval(input()))
c = eval(input())
W = 0
R = 0
for x in c:
    if x == "R":
        R += 1
ans = R
for x in c:
    if x == "W":
        W += 1
    else:
        R -= 1
    ans = min(ans, max(R, W))
print(ans)

-right = N - 1 -left = 0 -ans = 0 -flag = False -while True: -    if c[right] == "W": -        if (right >= 1) and (right > left + 1): -            right -= 1 -            continue -        else: -            break +W = 0 +R = 0 +for x in c: +    if x == "R": +        R += 1 +ans = R +for x in c: +    if x == "W": +        W += 1 -        while True: -            if c[left] == "R": -                if (left < N) and (left < right - 1): -                    left += 1 -                    continue -                else: -                    flag = True -                    break -            else: -                ans += 1 -                left += 1 -                right -= 1 -                break -        if flag: -            break +        R -= 1 +    ans = min(ans, max(R, W))