program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n,a,b
    if(mod(b-a,2)==0)then
        write(*,*)(b-a)/2
        stop
    elseif(b==n .or.a==1)then

        write(*,*)(b-a+1)/2
    elseif(2*n-b-a+1<a+b-1)then
        write(*,*)(2*n-b-a+1)/2
    else
        write(*,*)(a+b-1)/2
    end if


    stop
end program sample
  

