import heapq


def main():
    _ = int(input())
    A = list(input())
    R_inds = []
    W_inds = []
    for i in range(len(A)):
        if A[i] == "R":
            R_inds.append(i*(-1))
        else:
            W_inds.append(i)

    if len(R_inds) == 0 or len(W_inds) == 0:
        print(0)
        return

    heapq.heapify(R_inds)
    heapq.heapify(W_inds)
    cnt = 0
    r_i = abs(heapq.heappop(R_inds))
    w_i = heapq.heappop(W_inds)
    while r_i > w_i:
        cnt += 1
        r_i = abs(heapq.heappushpop(R_inds, w_i*(-1)))
        w_i = heapq.heappushpop(W_inds, r_i)

    print(cnt)


if __name__ == '__main__':
    main() import heapq heapq def main():
    _ = int(input())
    A = list(input())
    R_inds = []
    W_inds = []
    for i in range(len(A)):
        if A[i] == "R":
            R_inds.append(i*(-1))
        else:
            W_inds.append(i)

    if len(R_inds) == 0 or len(W_inds) == 0:
        print(0)
        return

    heapq.heapify(R_inds)
    heapq.heapify(W_inds)
    cnt = 0
    r_i = abs(heapq.heappop(R_inds))
    w_i = heapq.heappop(W_inds)
    while r_i > w_i:
        cnt += 1
        r_i = abs(heapq.heappushpop(R_inds, w_i*(-1)))
        w_i = heapq.heappushpop(W_inds, r_i)

    print(cnt) main _ = int(input()) _ int(input()) int input() input A = list(input()) A list(input()) list input() input R_inds = [] R_inds [] W_inds = [] W_inds [] for i in range(len(A)):
        if A[i] == "R":
            R_inds.append(i*(-1))
        else:
            W_inds.append(i)

     i range(len(A)) range len(A) len A if A[i] == "R":
            R_inds.append(i*(-1))
        else:
            W_inds.append(i)

     A[i] == "R" A[i] A i "R" R_inds.append(i*(-1)) R_inds.append R_inds append i*(-1) i -1 W_inds.append(i) W_inds.append W_inds append i if len(R_inds) == 0 or len(W_inds) == 0:
        print(0)
        return

     len(R_inds) == 0 or len(W_inds) == 0 len(R_inds) == 0 len(R_inds) len R_inds 0 len(W_inds) == 0 len(W_inds) len W_inds 0 print(0) print 0 return heapq.heapify(R_inds) heapq.heapify heapq heapify R_inds heapq.heapify(W_inds) heapq.heapify heapq heapify W_inds cnt = 0 cnt 0 r_i = abs(heapq.heappop(R_inds)) r_i abs(heapq.heappop(R_inds)) abs heapq.heappop(R_inds) heapq.heappop heapq heappop R_inds w_i = heapq.heappop(W_inds) w_i heapq.heappop(W_inds) heapq.heappop heapq heappop W_inds while r_i > w_i:
        cnt += 1
        r_i = abs(heapq.heappushpop(R_inds, w_i*(-1)))
        w_i = heapq.heappushpop(W_inds, r_i)

     r_i > w_i r_i w_i cnt += 1 cnt 1 r_i = abs(heapq.heappushpop(R_inds, w_i*(-1))) r_i abs(heapq.heappushpop(R_inds, w_i*(-1))) abs heapq.heappushpop(R_inds, w_i*(-1)) heapq.heappushpop heapq heappushpop R_inds w_i*(-1) w_i -1 w_i = heapq.heappushpop(W_inds, r_i) w_i heapq.heappushpop(W_inds, r_i) heapq.heappushpop heapq heappushpop W_inds r_i print(cnt) print cnt if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    _ = int(input())
    A = list(input())
    R_inds = []
    W_inds = []
    for i in range(len(A)):
        if A[i] == "R":
            R_inds.append(i*(-1))
        else:
            W_inds.append(i)

    if len(R_inds) == 0 or len(W_inds) == 0:
        print(0)
        return

    heapq.heapify(R_inds)
    heapq.heapify(W_inds)
    cnt = 0
    r_i = abs(heapq.heappop(R_inds))
    w_i = heapq.heappop(W_inds)
    while r_i > w_i:
        cnt += 1
        r_i = abs(heapq.heappushpop(R_inds, w_i*(-1)))
        w_i = heapq.heappushpop(W_inds, r_i)

    print(cnt) def main():
    _ = int(input())
    A = list(input())
    R_inds = []
    W_inds = []
    for i in range(len(A)):
        if A[i] == "R":
            R_inds.append(i*(-1))
        else:
            W_inds.append(i)

    if len(R_inds) == 0 or len(W_inds) == 0:
        print(0)
        return

    heapq.heapify(R_inds)
    heapq.heapify(W_inds)
    cnt = 0
    r_i = abs(heapq.heappop(R_inds))
    w_i = heapq.heappop(W_inds)
    while r_i > w_i:
        cnt += 1
        r_i = abs(heapq.heappushpop(R_inds, w_i*(-1)))
        w_i = heapq.heappushpop(W_inds, r_i)

    print(cnt) main
import heapq


def main():
    _ = int(input())
    A = list(input())
    R_inds = []
    W_inds = []
    for i in range(len(A)):
        if A[i] == "R":
            R_inds.append(i*(-1))
        else:
            W_inds.append(i)

    if len(R_inds) == 0 or len(W_inds) == 0:
        print(0)
        return

    heapq.heapify(R_inds)
    heapq.heapify(W_inds)
    cnt = 0
    r_i = abs(heapq.heappop(R_inds))
    w_i = heapq.heappop(W_inds)
    while r_i > w_i:
        cnt += 1
        r_i = abs(heapq.heappushpop(R_inds, w_i*(-1)))
        w_i = heapq.heappushpop(W_inds, r_i)

    print(cnt)


if __name__ == '__main__':
    main()
