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
    else
        if(n-a<b-1)then
            write(*,*)n-a
        else
            write(*,*)b-1
        end if
    end if
    

    stop
end program sample
  

