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