main :: IO ()
main = do
    input <- getLine
    let [tables, first, second] = (map read $ words input) :: [Int]
    print $ calc 0 (min first second) (max first second)

calc :: Int -> Int -> Int -> Int
calc count first second
    | first == second = count
    | first == 1 && second - first > 1 = calc (count + 1) 2 (second - 1)
    | first == 1 = calc (count + 1) first (second - 1)
    | second - first == 1 = calc (count + 1) (first - 1) (second - 1)
    | otherwise = calc (count + 1) (first + 1) (second - 1)
