N = int(eval(input()))

c = list(eval(input()))

r, w = 0, 0

r = c.count('R')

a = r

for i in range(N):

    if c[i] == 'R':

        r -= 1

    else:

        w += 1

    ai = max(r, w)

    a = min(a, ai)

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

c = list(eval(input()))

r = c.count('R')

rr = c[:r].count('R')

print((r - rr))
N = int(eval(input()))
c = list(eval(input()))
r, w = 0, 0
r = c.count("R")
a = r
for i in range(N):
    if c[i] == "R":
        r -= 1
    else:
        w += 1
    ai = max(r, w)
    a = min(a, ai)
print(a)

N = int(eval(input()))
c = list(eval(input()))
r = c.count("R")
rr = c[:r].count("R")
print((r - rr))

-r, w = 0, 0 -a = r -for i in range(N): -    if c[i] == "R": -        r -= 1 -    else: -        w += 1 -    ai = max(r, w) -    a = min(a, ai) -print(a) +rr = c[:r].count("R") +print((r - rr))