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