N = int(input())
C = input()

W_total = C.count("W")
R_total = N - W_total
w_cur = 0
r_cur = R_total
ans = R_total
cur = 0

for i in range(N):
    if C[i] == "W":
        w_cur += 1
    else:
        r_cur -= 1

    ans = min(ans, min(w_cur, r_cur) + abs(w_cur - r_cur))

print(ans) N = int(input()) N int(input()) int input() input C = input() C input() input W_total = C.count("W") W_total C.count("W") C.count C count "W" R_total = N - W_total R_total N - W_total N W_total w_cur = 0 w_cur 0 r_cur = R_total r_cur R_total ans = R_total ans R_total cur = 0 cur 0 for i in range(N):
    if C[i] == "W":
        w_cur += 1
    else:
        r_cur -= 1

    ans = min(ans, min(w_cur, r_cur) + abs(w_cur - r_cur)) i range(N) range N if C[i] == "W":
        w_cur += 1
    else:
        r_cur -= 1

     C[i] == "W" C[i] C i "W" w_cur += 1 w_cur 1 r_cur -= 1 r_cur 1 ans = min(ans, min(w_cur, r_cur) + abs(w_cur - r_cur)) ans min(ans, min(w_cur, r_cur) + abs(w_cur - r_cur)) min ans min(w_cur, r_cur) + abs(w_cur - r_cur) min(w_cur, r_cur) min w_cur r_cur abs(w_cur - r_cur) abs w_cur - r_cur w_cur r_cur print(ans) print ans r_cur = R_total R_total r_cur w_cur = 0 0 w_cur r_cur -= 1 1 r_cur cur = 0 0 cur C = input() input() C R_total = N - W_total N - W_total R_total W_total = C.count("W") C.count("W") W_total w_cur += 1 1 w_cur ans = R_total R_total ans N = int(input()) int(input()) N ans = min(ans, min(w_cur, r_cur) + abs(w_cur - r_cur)) min(ans, min(w_cur, r_cur) + abs(w_cur - r_cur)) ans
N = int(input())
C = input()

W_total = C.count("W")
R_total = N - W_total
w_cur = 0
r_cur = R_total
ans = R_total
cur = 0

for i in range(N):
    if C[i] == "W":
        w_cur += 1
    else:
        r_cur -= 1

    ans = min(ans, min(w_cur, r_cur) + abs(w_cur - r_cur))

print(ans)