# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


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

    count = 0
    visited = 0
    r = stones[::-1]
    for i in range(N):
        if stones[i] == "W":
            j = r.find('R', visited, N-i)
            if j > -1:
                visited = j + 1
                count += 1

    return count


def main():
    print(solve())


if __name__ == "__main__":
    main() def solve():
    N = int(input())
    stones = input()

    count = 0
    visited = 0
    r = stones[::-1]
    for i in range(N):
        if stones[i] == "W":
            j = r.find('R', visited, N-i)
            if j > -1:
                visited = j + 1
                count += 1

    return count solve N = int(input()) N int(input()) int input() input stones = input() stones input() input count = 0 count 0 visited = 0 visited 0 r = stones[::-1] r stones[::-1] stones ::-1 -1 for i in range(N):
        if stones[i] == "W":
            j = r.find('R', visited, N-i)
            if j > -1:
                visited = j + 1
                count += 1

     i range(N) range N if stones[i] == "W":
            j = r.find('R', visited, N-i)
            if j > -1:
                visited = j + 1
                count += 1

     stones[i] == "W" stones[i] stones i "W" j = r.find('R', visited, N-i) j r.find('R', visited, N-i) r.find r find 'R' visited N-i N i if j > -1:
                visited = j + 1
                count += 1

     j > -1 j -1 visited = j + 1 visited j + 1 j 1 count += 1 count 1 return count count def main():
    print(solve()) main print(solve()) print solve() solve if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    print(solve()) def main():
    print(solve()) main def solve():
    N = int(input())
    stones = input()

    count = 0
    visited = 0
    r = stones[::-1]
    for i in range(N):
        if stones[i] == "W":
            j = r.find('R', visited, N-i)
            if j > -1:
                visited = j + 1
                count += 1

    return count def solve():
    N = int(input())
    stones = input()

    count = 0
    visited = 0
    r = stones[::-1]
    for i in range(N):
        if stones[i] == "W":
            j = r.find('R', visited, N-i)
            if j > -1:
                visited = j + 1
                count += 1

    return count solve
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


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

    count = 0
    visited = 0
    r = stones[::-1]
    for i in range(N):
        if stones[i] == "W":
            j = r.find('R', visited, N-i)
            if j > -1:
                visited = j + 1
                count += 1

    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()
