N = int(input())
S = input()
redPref = [0 for i in range(0, N)]

if S[0] == 'R':
    redPref[0] += 1

for i in range(1, N):
    redPref[i] += redPref[i - 1]
    if S[i] == 'R':
        redPref[i] += 1

def query(l, r, pref):
    a, b = 0, pref[r]
    if l - 1 >= 0:
        a = pref[l - 1]
    return b - a


ans = min(N - redPref[-1], redPref[-1])

for i in range(0, N - 1):
    leftRed = query(0, i, redPref)
    leftWhite = i - leftRed + 1

    rightRed = query(i + 1, N - 1, redPref)
    rightWhite = ((N - 1) - (i + 1) + 1) - rightRed

    swaps = min(leftWhite, rightRed)
    leftWhite -= swaps
    rightRed -= swaps
    leftRed += swaps
    rightWhite += swaps

    ans = min(ans, leftWhite + rightRed + swaps)

print(ans) N = int(input()) N int(input()) int input() input S = input() S input() input 0 for i in range(0, N) for i in range(0, N) i range(0, N) range 0 N for i in range(0, N) 0 redPref = [0 for i in range(0, N)] redPref [0 for i in range(0, N)] if S[0] == 'R':
    redPref[0] += 1 S[0] == 'R' S[0] S 0 'R' redPref[0] += 1 redPref[0] redPref 0 1 for i in range(1, N):
    redPref[i] += redPref[i - 1]
    if S[i] == 'R':
        redPref[i] += 1 i range(1, N) range 1 N redPref[i] += redPref[i - 1] redPref[i] redPref i redPref[i - 1] redPref i - 1 i 1 if S[i] == 'R':
        redPref[i] += 1 S[i] == 'R' S[i] S i 'R' redPref[i] += 1 redPref[i] redPref i 1 def query(l, r, pref):
    a, b = 0, pref[r]
    if l - 1 >= 0:
        a = pref[l - 1]
    return b - a query a, b = 0, pref[r] a 0 b pref[r] pref r if l - 1 >= 0:
        a = pref[l - 1]
     l - 1 >= 0 l - 1 l 1 0 a = pref[l - 1] a pref[l - 1] pref l - 1 l 1 return b - a b - a b a l l r r pref pref ans = min(N - redPref[-1], redPref[-1]) ans min(N - redPref[-1], redPref[-1]) min N - redPref[-1] N redPref[-1] redPref -1 redPref[-1] redPref -1 for i in range(0, N - 1):
    leftRed = query(0, i, redPref)
    leftWhite = i - leftRed + 1

    rightRed = query(i + 1, N - 1, redPref)
    rightWhite = ((N - 1) - (i + 1) + 1) - rightRed

    swaps = min(leftWhite, rightRed)
    leftWhite -= swaps
    rightRed -= swaps
    leftRed += swaps
    rightWhite += swaps

    ans = min(ans, leftWhite + rightRed + swaps) i range(0, N - 1) range 0 N - 1 N 1 leftRed = query(0, i, redPref) leftRed query(0, i, redPref) query 0 i redPref leftWhite = i - leftRed + 1 leftWhite i - leftRed + 1 i - leftRed i leftRed 1 rightRed = query(i + 1, N - 1, redPref) rightRed query(i + 1, N - 1, redPref) query i + 1 i 1 N - 1 N 1 redPref rightWhite = ((N - 1) - (i + 1) + 1) - rightRed rightWhite ((N - 1) - (i + 1) + 1) - rightRed (N - 1) - (i + 1) + 1 (N - 1) - (i + 1) N - 1 N 1 i + 1 i 1 1 rightRed swaps = min(leftWhite, rightRed) swaps min(leftWhite, rightRed) min leftWhite rightRed leftWhite -= swaps leftWhite swaps rightRed -= swaps rightRed swaps leftRed += swaps leftRed swaps rightWhite += swaps rightWhite swaps ans = min(ans, leftWhite + rightRed + swaps) ans min(ans, leftWhite + rightRed + swaps) min ans leftWhite + rightRed + swaps leftWhite + rightRed leftWhite rightRed swaps print(ans) print ans leftWhite -= swaps swaps leftWhite S = input() input() S redPref = [0 for i in range(0, N)] [0 for i in range(0, N)] redPref rightWhite += swaps swaps rightWhite leftWhite = i - leftRed + 1 i - leftRed + 1 leftWhite ans = min(ans, leftWhite + rightRed + swaps) min(ans, leftWhite + rightRed + swaps) ans ans = min(N - redPref[-1], redPref[-1]) min(N - redPref[-1], redPref[-1]) ans swaps = min(leftWhite, rightRed) min(leftWhite, rightRed) swaps rightRed -= swaps swaps rightRed rightRed = query(i + 1, N - 1, redPref) query(i + 1, N - 1, redPref) rightRed leftRed = query(0, i, redPref) query(0, i, redPref) leftRed def query(l, r, pref):
    a, b = 0, pref[r]
    if l - 1 >= 0:
        a = pref[l - 1]
    return b - a def query(l, r, pref):
    a, b = 0, pref[r]
    if l - 1 >= 0:
        a = pref[l - 1]
    return b - a query rightWhite = ((N - 1) - (i + 1) + 1) - rightRed ((N - 1) - (i + 1) + 1) - rightRed rightWhite N = int(input()) int(input()) N leftRed += swaps swaps leftRed
N = int(input())
S = input()
redPref = [0 for i in range(0, N)]

if S[0] == 'R':
    redPref[0] += 1

for i in range(1, N):
    redPref[i] += redPref[i - 1]
    if S[i] == 'R':
        redPref[i] += 1

def query(l, r, pref):
    a, b = 0, pref[r]
    if l - 1 >= 0:
        a = pref[l - 1]
    return b - a


ans = min(N - redPref[-1], redPref[-1])

for i in range(0, N - 1):
    leftRed = query(0, i, redPref)
    leftWhite = i - leftRed + 1

    rightRed = query(i + 1, N - 1, redPref)
    rightWhite = ((N - 1) - (i + 1) + 1) - rightRed

    swaps = min(leftWhite, rightRed)
    leftWhite -= swaps
    rightRed -= swaps
    leftRed += swaps
    rightWhite += swaps

    ans = min(ans, leftWhite + rightRed + swaps)

print(ans)
