program table_tennis_training
  implicit none
  integer(8) :: n, a, b
  read(*,*) n, a, b
  if (mod(b - a, 2) == 0) then
    write(*,'(i0)') (b - a) / 2
  else
    write(*,'(i0)') min(a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2)
  end if
end program table_tennis_training