program answer
  implicit none
  integer(16) :: N, A, B

  read(*,*) N, A, B

  if(mod(B-A,2)==0) then
     write(*,*) (B-A)/2
  else
     write(*,*) min(B-1,N-A,A+(B-A-1)/2,N-B+1+(B-A-1)/2)
  end if

  stop
 end program answer