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