program AGC041A
    implicit none
    integer(8)::N,A,B
    read*,N,A,B
    if(mod(B-A,2)==0)then
        print'(i0)',(B-A)/2
    else
        print'(i0)',min(N-B,A-1)+(B-A-1)/2+1
    end if
end program AGC041A