import sys

readline = sys.stdin.readline

from collections import deque



def solve():

    N = int(readline())

    C = readline().rstrip()



    R, W = 'R', 'W'

    reds = deque(i for i in range(len(C)) if C[i] == 'R')

    whites = deque(i for i in range(len(C)) if C[i] == 'W')



    count = 0

    while len(whites) > 0 and len(reds) > 0 and whites[0] < reds[-1]:

        reds.pop()

        whites.popleft()

        count += 1

    

    print(count)



solve()
import sys

readline = sys.stdin.readline



def solve():

    N = int(readline())

    C = readline().rstrip()



    reds = [i for i in range(len(C)) if C[i] == 'R']

    whites = [i for i in range(len(C)) if C[i] == 'W']



    i = 0

    n = min(len(reds), len(whites))

    while i < n and reds[-1-i] > whites[i]:

        i += 1

    

    print(i)



solve()
import sys

readline = sys.stdin.readline
from collections import deque


def solve():
    N = int(readline())
    C = readline().rstrip()
    R, W = "R", "W"
    reds = deque(i for i in range(len(C)) if C[i] == "R")
    whites = deque(i for i in range(len(C)) if C[i] == "W")
    count = 0
    while len(whites) > 0 and len(reds) > 0 and whites[0] < reds[-1]:
        reds.pop()
        whites.popleft()
        count += 1
    print(count)


solve()

import sys

readline = sys.stdin.readline


def solve():
    N = int(readline())
    C = readline().rstrip()
    reds = [i for i in range(len(C)) if C[i] == "R"]
    whites = [i for i in range(len(C)) if C[i] == "W"]
    i = 0
    n = min(len(reds), len(whites))
    while i < n and reds[-1 - i] > whites[i]:
        i += 1
    print(i)


solve()

-from collections import deque -    R, W = "R", "W" -    reds = deque(i for i in range(len(C)) if C[i] == "R") -    whites = deque(i for i in range(len(C)) if C[i] == "W") -    count = 0 -    while len(whites) > 0 and len(reds) > 0 and whites[0] < reds[-1]: -        reds.pop() -        whites.popleft() -        count += 1 -    print(count) +    reds = [i for i in range(len(C)) if C[i] == "R"] +    whites = [i for i in range(len(C)) if C[i] == "W"] +    i = 0 +    n = min(len(reds), len(whites)) +    while i < n and reds[-1 - i] > whites[i]: +        i += 1 +    print(i)