import sys
import numpy as np  # noqa

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


K = int(readline())
C = readline().rstrip().decode()

a = 0  # a: 赤から白に変える操作
b = 0  # b: 白から赤に変える操作
for i in range(len(C)):
    if C[i] == 'R':
        a += 1
mn = a
for i in range(len(C)):
    if C[i] == 'R':
        a -= 1
    else:
        b += 1
    mn = min(mn, min(a, b) + abs(a-b))
print(mn) import sys sys import numpy as np numpy read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines K = int(readline()) K int(readline()) int readline() readline C = readline().rstrip().decode() C readline().rstrip().decode() ().rstrip().decode ().rstrip() ().rstrip () readline rstrip decode a = 0 a 0 b = 0 b 0 for i in range(len(C)):
    if C[i] == 'R':
        a += 1 i range(len(C)) range len(C) len C if C[i] == 'R':
        a += 1 C[i] == 'R' C[i] C i 'R' a += 1 a 1 mn = a mn a for i in range(len(C)):
    if C[i] == 'R':
        a -= 1
    else:
        b += 1
    mn = min(mn, min(a, b) + abs(a-b)) i range(len(C)) range len(C) len C if C[i] == 'R':
        a -= 1
    else:
        b += 1
     C[i] == 'R' C[i] C i 'R' a -= 1 a 1 b += 1 b 1 mn = min(mn, min(a, b) + abs(a-b)) mn min(mn, min(a, b) + abs(a-b)) min mn min(a, b) + abs(a-b) min(a, b) min a b abs(a-b) abs a-b a b print(mn) print mn C = readline().rstrip().decode() readline().rstrip().decode() C b += 1 1 b mn = min(mn, min(a, b) + abs(a-b)) min(mn, min(a, b) + abs(a-b)) mn read = sys.stdin.buffer.read sys.stdin.buffer.read read readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline a += 1 1 a a -= 1 1 a K = int(readline()) int(readline()) K readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines a = 0 0 a b = 0 0 b mn = a a mn
import sys
import numpy as np  # noqa

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


K = int(readline())
C = readline().rstrip().decode()

a = 0  # a: 赤から白に変える操作
b = 0  # b: 白から赤に変える操作
for i in range(len(C)):
    if C[i] == 'R':
        a += 1
mn = a
for i in range(len(C)):
    if C[i] == 'R':
        a -= 1
    else:
        b += 1
    mn = min(mn, min(a, b) + abs(a-b))
print(mn)
