#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    C = input()

    num_r = C.count("R")
    num_w = C.count("W")
    ans = min(num_r, num_w)

    left_r = 0
    left_w = 0
    for i in range(N):
        left_r += C[i] == 'R'
        left_w += C[i] == 'W'

        right_r = num_r - left_r
        right_w = num_w - left_w
        ans = min(ans, min(left_w, right_r) + abs(left_w - right_r))

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main() from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys sys.setrecursionlimit(10000) sys.setrecursionlimit sys setrecursionlimit 10000 INF = float("inf") INF float("inf") float "inf" YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" YES "YES" Yes "Yes" yes "yes" NO "NO" No "No" no "no" dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] dy4 [0, 1, 0, -1] 0 1 0 -1 dx4 [1, 0, -1, 0] 1 0 -1 0 dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] dy8 [0, -1, 0, 1, 1, -1, -1, 1] 0 -1 0 1 1 -1 -1 1 dx8 [1, 0, -1, 0, 1, 1, -1, -1] 1 0 -1 0 1 1 -1 -1 def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W inside return 0 <= y < H and 0 <= x < W 0 <= y < H and 0 <= x < W 0 <= y < H 0 <= y 0 y H 0 <= x < W 0 <= x 0 x W y y x x H H W W def ceil(a, b):
    return (a + b - 1) // b ceil return (a + b - 1) // b (a + b - 1) // b a + b - 1 a + b a b 1 b a a b b def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2 sum_of_arithmetic_progression return n * (2 * s + (n - 1) * d) // 2 n * (2 * s + (n - 1) * d) // 2 n * (2 * s + (n - 1) * d) n 2 * s + (n - 1) * d 2 * s 2 s (n - 1) * d n - 1 n 1 d 2 s s d d n n def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b) gcd if b == 0:
        return a
     b == 0 b 0 return a a return gcd(b, a % b) gcd(b, a % b) gcd b a % b a b a a b b def lcm(a, b):
    g = gcd(a, b)
    return a / g * b lcm g = gcd(a, b) g gcd(a, b) gcd a b return a / g * b a / g * b a / g a g b a a b b def solve():
    N = int(input())
    C = input()

    num_r = C.count("R")
    num_w = C.count("W")
    ans = min(num_r, num_w)

    left_r = 0
    left_w = 0
    for i in range(N):
        left_r += C[i] == 'R'
        left_w += C[i] == 'W'

        right_r = num_r - left_r
        right_w = num_w - left_w
        ans = min(ans, min(left_w, right_r) + abs(left_w - right_r))

    print(ans) solve N = int(input()) N int(input()) int input() input C = input() C input() input num_r = C.count("R") num_r C.count("R") C.count C count "R" num_w = C.count("W") num_w C.count("W") C.count C count "W" ans = min(num_r, num_w) ans min(num_r, num_w) min num_r num_w left_r = 0 left_r 0 left_w = 0 left_w 0 for i in range(N):
        left_r += C[i] == 'R'
        left_w += C[i] == 'W'

        right_r = num_r - left_r
        right_w = num_w - left_w
        ans = min(ans, min(left_w, right_r) + abs(left_w - right_r))

     i range(N) range N left_r += C[i] == 'R' left_r C[i] == 'R' C[i] C i 'R' left_w += C[i] == 'W' left_w C[i] == 'W' C[i] C i 'W' right_r = num_r - left_r right_r num_r - left_r num_r left_r right_w = num_w - left_w right_w num_w - left_w num_w left_w ans = min(ans, min(left_w, right_r) + abs(left_w - right_r)) ans min(ans, min(left_w, right_r) + abs(left_w - right_r)) min ans min(left_w, right_r) + abs(left_w - right_r) min(left_w, right_r) min left_w right_r abs(left_w - right_r) abs left_w - right_r left_w right_r print(ans) print ans def main():
    solve() main solve() solve if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main no = "YES", "Yes", "yes", "NO", "No", "no" "no" no def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b) def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b) gcd dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] [0, 1, 0, -1] dy4 dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] [1, 0, -1, 0, 1, 1, -1, -1] dx8 INF = float("inf") float("inf") INF def main():
    solve() def main():
    solve() main Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" "Yes" Yes No, no = "YES", "Yes", "yes", "NO", "No", "no" "No" No dx4 = [0, 1, 0, -1], [1, 0, -1, 0] [1, 0, -1, 0] dx4 yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" "yes" yes def solve():
    N = int(input())
    C = input()

    num_r = C.count("R")
    num_w = C.count("W")
    ans = min(num_r, num_w)

    left_r = 0
    left_w = 0
    for i in range(N):
        left_r += C[i] == 'R'
        left_w += C[i] == 'W'

        right_r = num_r - left_r
        right_w = num_w - left_w
        ans = min(ans, min(left_w, right_r) + abs(left_w - right_r))

    print(ans) def solve():
    N = int(input())
    C = input()

    num_r = C.count("R")
    num_w = C.count("W")
    ans = min(num_r, num_w)

    left_r = 0
    left_w = 0
    for i in range(N):
        left_r += C[i] == 'R'
        left_w += C[i] == 'W'

        right_r = num_r - left_r
        right_w = num_w - left_w
        ans = min(ans, min(left_w, right_r) + abs(left_w - right_r))

    print(ans) solve def lcm(a, b):
    g = gcd(a, b)
    return a / g * b def lcm(a, b):
    g = gcd(a, b)
    return a / g * b lcm YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" "YES" YES def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W inside def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2 def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2 sum_of_arithmetic_progression def ceil(a, b):
    return (a + b - 1) // b def ceil(a, b):
    return (a + b - 1) // b ceil dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] [0, -1, 0, 1, 1, -1, -1, 1] dy8 NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" "NO" NO
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    C = input()

    num_r = C.count("R")
    num_w = C.count("W")
    ans = min(num_r, num_w)

    left_r = 0
    left_w = 0
    for i in range(N):
        left_r += C[i] == 'R'
        left_w += C[i] == 'W'

        right_r = num_r - left_r
        right_w = num_w - left_w
        ans = min(ans, min(left_w, right_r) + abs(left_w - right_r))

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()
