program alter_altar
    character(200001) :: c = '0'
    integer n
    integer :: r(200001) = 0
    integer :: w(200001) = 0
    integer :: i = 1
    integer :: k = 1
    integer :: j = 0
    read *, n
    read *, c
    do
        if(i == 1)then
            w(i) = index(c,'W')
            r(k) = index(c,'R',back=.true.)
                c(w(i):w(i)) = 'R'
                c(r(k):r(k)) = 'W'
                j = j + 1
            if(w(i) > r(k) .or. w(i) == 0 .or. r(k) == 0) exit
       else
            w(i) = index(c(w(i+1):),'W')
            r(k) = index(c(:r(k-1)),'R',back=.true.)
            c(w(i):w(i)) = 'R'
            c(r(k):r(k)) = 'W'
            j = j + 1
        end if
    end do
    print *, j
end program