from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n = ri()
    C = input()
    if C[0] == "R":
        R = [1]
        W = [0]
    else:
        R = [0]
        W = [1]

    for c in C[1:]:
        if c == "R":
            R.append(1 + R[-1])
            W.append(W[-1])
        else:
            W.append(1 + W[-1])
            R.append(R[-1])

    best_cost = min(R[-1], W[-1])
    for i in range(n):
        rl = R[i]
        wl = W[i]
        rr = R[-1] - rl
        wr = W[-1] - wl
        swaps = min(wl, rr)
        flips = wl + rr - 2 * swaps
        best_cost = min(best_cost, flips + swaps)
    print (best_cost)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve() from collections import defaultdict as dd from collections import deque import bisect bisect import heapq heapq def ri():
    return int(input()) ri return int(input()) int(input()) int input() input def rl():
    return list(map(int, input().split())) rl return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def solve():
    n = ri()
    C = input()
    if C[0] == "R":
        R = [1]
        W = [0]
    else:
        R = [0]
        W = [1]

    for c in C[1:]:
        if c == "R":
            R.append(1 + R[-1])
            W.append(W[-1])
        else:
            W.append(1 + W[-1])
            R.append(R[-1])

    best_cost = min(R[-1], W[-1])
    for i in range(n):
        rl = R[i]
        wl = W[i]
        rr = R[-1] - rl
        wr = W[-1] - wl
        swaps = min(wl, rr)
        flips = wl + rr - 2 * swaps
        best_cost = min(best_cost, flips + swaps)
    print (best_cost) solve n = ri() n ri() ri C = input() C input() input if C[0] == "R":
        R = [1]
        W = [0]
    else:
        R = [0]
        W = [1]

     C[0] == "R" C[0] C 0 "R" R = [1] R [1] 1 W = [0] W [0] 0 R = [0] R [0] 0 W = [1] W [1] 1 for c in C[1:]:
        if c == "R":
            R.append(1 + R[-1])
            W.append(W[-1])
        else:
            W.append(1 + W[-1])
            R.append(R[-1])

     c C[1:] C 1: 1 if c == "R":
            R.append(1 + R[-1])
            W.append(W[-1])
        else:
            W.append(1 + W[-1])
            R.append(R[-1])

     c == "R" c "R" R.append(1 + R[-1]) R.append R append 1 + R[-1] 1 R[-1] R -1 W.append(W[-1]) W.append W append W[-1] W -1 W.append(1 + W[-1]) W.append W append 1 + W[-1] 1 W[-1] W -1 R.append(R[-1]) R.append R append R[-1] R -1 best_cost = min(R[-1], W[-1]) best_cost min(R[-1], W[-1]) min R[-1] R -1 W[-1] W -1 for i in range(n):
        rl = R[i]
        wl = W[i]
        rr = R[-1] - rl
        wr = W[-1] - wl
        swaps = min(wl, rr)
        flips = wl + rr - 2 * swaps
        best_cost = min(best_cost, flips + swaps)
     i range(n) range n rl = R[i] rl R[i] R i wl = W[i] wl W[i] W i rr = R[-1] - rl rr R[-1] - rl R[-1] R -1 rl wr = W[-1] - wl wr W[-1] - wl W[-1] W -1 wl swaps = min(wl, rr) swaps min(wl, rr) min wl rr flips = wl + rr - 2 * swaps flips wl + rr - 2 * swaps wl + rr wl rr 2 * swaps 2 swaps best_cost = min(best_cost, flips + swaps) best_cost min(best_cost, flips + swaps) min best_cost flips + swaps flips swaps print (best_cost) print best_cost mode = 's' mode 's' if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve() mode == 'T' mode 'T' t = ri() t ri() ri for i in range(t):
        solve() i range(t) range t solve() solve solve() solve t = ri() ri() t mode = 's' 's' mode def ri():
    return int(input()) def ri():
    return int(input()) ri def rl():
    return list(map(int, input().split())) def rl():
    return list(map(int, input().split())) rl def solve():
    n = ri()
    C = input()
    if C[0] == "R":
        R = [1]
        W = [0]
    else:
        R = [0]
        W = [1]

    for c in C[1:]:
        if c == "R":
            R.append(1 + R[-1])
            W.append(W[-1])
        else:
            W.append(1 + W[-1])
            R.append(R[-1])

    best_cost = min(R[-1], W[-1])
    for i in range(n):
        rl = R[i]
        wl = W[i]
        rr = R[-1] - rl
        wr = W[-1] - wl
        swaps = min(wl, rr)
        flips = wl + rr - 2 * swaps
        best_cost = min(best_cost, flips + swaps)
    print (best_cost) def solve():
    n = ri()
    C = input()
    if C[0] == "R":
        R = [1]
        W = [0]
    else:
        R = [0]
        W = [1]

    for c in C[1:]:
        if c == "R":
            R.append(1 + R[-1])
            W.append(W[-1])
        else:
            W.append(1 + W[-1])
            R.append(R[-1])

    best_cost = min(R[-1], W[-1])
    for i in range(n):
        rl = R[i]
        wl = W[i]
        rr = R[-1] - rl
        wr = W[-1] - wl
        swaps = min(wl, rr)
        flips = wl + rr - 2 * swaps
        best_cost = min(best_cost, flips + swaps)
    print (best_cost) solve
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n = ri()
    C = input()
    if C[0] == "R":
        R = [1]
        W = [0]
    else:
        R = [0]
        W = [1]

    for c in C[1:]:
        if c == "R":
            R.append(1 + R[-1])
            W.append(W[-1])
        else:
            W.append(1 + W[-1])
            R.append(R[-1])

    best_cost = min(R[-1], W[-1])
    for i in range(n):
        rl = R[i]
        wl = W[i]
        rr = R[-1] - rl
        wr = W[-1] - wl
        swaps = min(wl, rr)
        flips = wl + rr - 2 * swaps
        best_cost = min(best_cost, flips + swaps)
    print (best_cost)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()
