from collections import deque
N = int(input())
C = input()
r = deque()
lr = 0
for i in range(N):
  if C[i] == 'R':
    lr += 1
    r.append(i)
ans = 0
for i in range(N):
  if lr == 0:
    break
  if C[i] == 'W':
    if i < r[-1]:
      ans += 1
      r.pop()
      lr -= 1
    else:
      break
print(ans) from collections import deque N = int(input()) N int(input()) int input() input C = input() C input() input r = deque() r deque() deque lr = 0 lr 0 for i in range(N):
  if C[i] == 'R':
    lr += 1
    r.append(i) i range(N) range N if C[i] == 'R':
    lr += 1
    r.append(i) C[i] == 'R' C[i] C i 'R' lr += 1 lr 1 r.append(i) r.append r append i ans = 0 ans 0 for i in range(N):
  if lr == 0:
    break
  if C[i] == 'W':
    if i < r[-1]:
      ans += 1
      r.pop()
      lr -= 1
    else:
      break i range(N) range N if lr == 0:
    break
   lr == 0 lr 0 break if C[i] == 'W':
    if i < r[-1]:
      ans += 1
      r.pop()
      lr -= 1
    else:
      break C[i] == 'W' C[i] C i 'W' if i < r[-1]:
      ans += 1
      r.pop()
      lr -= 1
    else:
      break i < r[-1] i r[-1] r -1 ans += 1 ans 1 r.pop() r.pop r pop lr -= 1 lr 1 break print(ans) print ans N = int(input()) int(input()) N r = deque() deque() r ans += 1 1 ans lr += 1 1 lr ans = 0 0 ans C = input() input() C lr -= 1 1 lr lr = 0 0 lr
from collections import deque
N = int(input())
C = input()
r = deque()
lr = 0
for i in range(N):
  if C[i] == 'R':
    lr += 1
    r.append(i)
ans = 0
for i in range(N):
  if lr == 0:
    break
  if C[i] == 'W':
    if i < r[-1]:
      ans += 1
      r.pop()
      lr -= 1
    else:
      break
print(ans)