program count_balls
    implicit none
    integer(8) n, r, b, i, j
    integer(8) :: ball = 0, ans = 0, blue = 0
    read *, n, b, r
    do i = 1, n
        if(ball .ge. n)exit
        do j = 1, b
            if(ball .ge. n)exit
            ball = ball + 1
            blue = blue + 1
            if(ball .ge. n)then
                ans = blue
                exit
            end if
        end do
        if(ball .le. n)then
            do j = 1, r
                if(ball .ge. n)exit
                ball = ball + 1
            end do
        end if
    end do
    print *, blue
end program