import sys
input = sys.stdin.readline

N = int(input())
S = input()[:-1]
R = S.count('R')
accR = [0]

for Si in S:
    accR.append(accR[-1]+(1 if Si=='R' else 0))

ans = 10**18

for i in range(N+1):
    ans = min(ans, abs(i-R)+abs(i-accR[i]))

print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input S = input()[:-1] S input()[:-1] () input :-1 -1 R = S.count('R') R S.count('R') S.count S count 'R' accR = [0] accR [0] 0 for Si in S:
    accR.append(accR[-1]+(1 if Si=='R' else 0)) Si S accR.append(accR[-1]+(1 if Si=='R' else 0)) accR.append accR append accR[-1]+(1 if Si=='R' else 0) accR[-1] accR -1 1 if Si=='R' else 0 Si=='R' Si 'R' 1 0 ans = 10**18 ans 10**18 10 18 for i in range(N+1):
    ans = min(ans, abs(i-R)+abs(i-accR[i])) i range(N+1) range N+1 N 1 ans = min(ans, abs(i-R)+abs(i-accR[i])) ans min(ans, abs(i-R)+abs(i-accR[i])) min ans abs(i-R)+abs(i-accR[i]) abs(i-R) abs i-R i R abs(i-accR[i]) abs i-accR[i] i accR[i] accR i print(ans) print ans ans = min(ans, abs(i-R)+abs(i-accR[i])) min(ans, abs(i-R)+abs(i-accR[i])) ans S = input()[:-1] input()[:-1] S ans = 10**18 10**18 ans R = S.count('R') S.count('R') R accR = [0] [0] accR N = int(input()) int(input()) N input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline

N = int(input())
S = input()[:-1]
R = S.count('R')
accR = [0]

for Si in S:
    accR.append(accR[-1]+(1 if Si=='R' else 0))

ans = 10**18

for i in range(N+1):
    ans = min(ans, abs(i-R)+abs(i-accR[i]))

print(ans)