program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,l,r,cnt=0
    character(:),allocatable:: c

    read*, n
    allocate(character(n):: c)
    read*, c(:)
    l=1; r=n
    do while (l < r)
        do while(c(l:l) == "R")
            l=l+1
            if (l > n) exit
        end do

        do while(c(r:r) == "W")
            r=r-1
            if (r < 1) exit
        end do

        if (l < r) then
            cnt=cnt+1
            l=l+1; r=r-1
        end if
    end do
    print'(i0)', cnt
end program main