import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  (n:a:b:_) <- map read . words <$> getLine
  print $ solve' n a b 0

solve :: Integer -> Integer -> Integer -> Integer
solve n a b
  | (b - a) `mod` 2 == 0 = (b - a) `div` 2
  | otherwise = min ((a + b - 1) `div` 2) ((n * 2 - a - b - 1) `div` 2)

solve' :: Integer -> Integer -> Integer -> Integer -> Integer
solve' n a b acc
  | a == b = acc
  | a == 0 && b == 1 = acc
  | a == n && b == n + 1 = acc
  | (b - a) `mod` 2 == 0 = (b - a) `div` 2
  | a == 0 = solve' n 2 (b - 1) (acc + 1)
  | b == n + 1 = solve' n (a + 1) (n - 1) (acc + 1)
  | a <= (n - b) = solve' n 0 (b - a) (acc + a)
  | otherwise = solve' n (a + (n - b + 1)) (n + 1) (acc + (n - b + 1))