import heapq

def main():
    N = int(input())
    C = list(input())
    R = []
    W = []
    for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
    if len(R) == 0 or len(W) == 0:
        print(0)
        exit()
    heapq.heapify(R)
    heapq.heapify(W)
    ans = 0
    while True:
        max_r = -1 * heapq.heappop(R)
        min_w = heapq.heappop(W)
        if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
    print(ans)


if __name__ == '__main__':
    main() import heapq heapq def main():
    N = int(input())
    C = list(input())
    R = []
    W = []
    for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
    if len(R) == 0 or len(W) == 0:
        print(0)
        exit()
    heapq.heapify(R)
    heapq.heapify(W)
    ans = 0
    while True:
        max_r = -1 * heapq.heappop(R)
        min_w = heapq.heappop(W)
        if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
    print(ans) main N = int(input()) N int(input()) int input() input C = list(input()) C list(input()) list input() input R = [] R [] W = [] W [] for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
     i c enumerate(C) enumerate C if c == 'R':
            R.append(-i)
        else:
            W.append(i)
     c == 'R' c 'R' R.append(-i) R.append R append -i i W.append(i) W.append W append i if len(R) == 0 or len(W) == 0:
        print(0)
        exit()
     len(R) == 0 or len(W) == 0 len(R) == 0 len(R) len R 0 len(W) == 0 len(W) len W 0 print(0) print 0 exit() exit heapq.heapify(R) heapq.heapify heapq heapify R heapq.heapify(W) heapq.heapify heapq heapify W ans = 0 ans 0 while True:
        max_r = -1 * heapq.heappop(R)
        min_w = heapq.heappop(W)
        if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
     True max_r = -1 * heapq.heappop(R) max_r -1 * heapq.heappop(R) -1 heapq.heappop(R) heapq.heappop heapq heappop R min_w = heapq.heappop(W) min_w heapq.heappop(W) heapq.heappop heapq heappop W if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
     max_r < min_w max_r min_w break heapq.heappush(R, -min_w) heapq.heappush heapq heappush R -min_w min_w heapq.heappush(W, max_r) heapq.heappush heapq heappush W max_r ans += 1 ans 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N = int(input())
    C = list(input())
    R = []
    W = []
    for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
    if len(R) == 0 or len(W) == 0:
        print(0)
        exit()
    heapq.heapify(R)
    heapq.heapify(W)
    ans = 0
    while True:
        max_r = -1 * heapq.heappop(R)
        min_w = heapq.heappop(W)
        if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
    print(ans) def main():
    N = int(input())
    C = list(input())
    R = []
    W = []
    for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
    if len(R) == 0 or len(W) == 0:
        print(0)
        exit()
    heapq.heapify(R)
    heapq.heapify(W)
    ans = 0
    while True:
        max_r = -1 * heapq.heappop(R)
        min_w = heapq.heappop(W)
        if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
    print(ans) main
import heapq

def main():
    N = int(input())
    C = list(input())
    R = []
    W = []
    for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
    if len(R) == 0 or len(W) == 0:
        print(0)
        exit()
    heapq.heapify(R)
    heapq.heapify(W)
    ans = 0
    while True:
        max_r = -1 * heapq.heappop(R)
        min_w = heapq.heappop(W)
        if max_r < min_w:
            break
        else:
            heapq.heappush(R, -min_w)
            heapq.heappush(W, max_r)
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
