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