import queue

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

R, W = queue.PriorityQueue(), queue.PriorityQueue()
for i in range(N):
    if S[i] == 'R':
        R.put(-i)
    else:
        W.put(i)

steps = 0
while True:
    if R.qsize() == 0 or W.qsize() == 0:
        break
    r, w = -R.get(), W.get()
    if r < w:
        break
    steps += 1

print(steps)
 import queue queue N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input R, W = queue.PriorityQueue(), queue.PriorityQueue() R queue.PriorityQueue() queue.PriorityQueue queue PriorityQueue W queue.PriorityQueue() queue.PriorityQueue queue PriorityQueue for i in range(N):
    if S[i] == 'R':
        R.put(-i)
    else:
        W.put(i) i range(N) range N if S[i] == 'R':
        R.put(-i)
    else:
        W.put(i) S[i] == 'R' S[i] S i 'R' R.put(-i) R.put R put -i i W.put(i) W.put W put i steps = 0 steps 0 while True:
    if R.qsize() == 0 or W.qsize() == 0:
        break
    r, w = -R.get(), W.get()
    if r < w:
        break
    steps += 1 True if R.qsize() == 0 or W.qsize() == 0:
        break
     R.qsize() == 0 or W.qsize() == 0 R.qsize() == 0 R.qsize() R.qsize R qsize 0 W.qsize() == 0 W.qsize() W.qsize W qsize 0 break r, w = -R.get(), W.get() r -R.get() R.get() R.get R get w W.get() W.get W get if r < w:
        break
     r < w r w break steps += 1 steps 1 print(steps) print steps N = int(input()) int(input()) N W = queue.PriorityQueue(), queue.PriorityQueue() queue.PriorityQueue() W R, W = queue.PriorityQueue(), queue.PriorityQueue() queue.PriorityQueue() R w = -R.get(), W.get() W.get() w steps = 0 0 steps r, w = -R.get(), W.get() -R.get() r steps += 1 1 steps S = list(input()) list(input()) S
import queue

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

R, W = queue.PriorityQueue(), queue.PriorityQueue()
for i in range(N):
    if S[i] == 'R':
        R.put(-i)
    else:
        W.put(i)

steps = 0
while True:
    if R.qsize() == 0 or W.qsize() == 0:
        break
    r, w = -R.get(), W.get()
    if r < w:
        break
    steps += 1

print(steps)

