program prob3
    implicit none
    integer(16)::n, a, b
    read(*,*) n, a, b
    if(mod(abs(a-b),2) == 0) then
        write(*,*) abs(a-b)/2
    else
        if(a-1 <= n-b) then
            b = b - a - 1
            write(*,*) b/2 + a
        else
            a = a + n - b - 1
            write(*,*) (b-a)/2 + (n-b)
        end if
    end if
    stop
end program