Scanf.scanf "%d %d %d" (fun n a b ->
    (if (a + b) mod 2 = 0 then abs (a - b) / 2 else
        let d1 = max a b - 1 in
        let d2 = min a b + ((abs (a - b)  - 1) / 2) in
        let a = n - a + 1 in
        let b = n - b + 1 in
        let d3 = max a b - 1 in
        let d4 = min a b + ((abs (a - b)  - 1) / 2) in
        min (min d1 d2) (min d3 d4)
    ) |> Printf.printf "%d\n"
)