Scanf.scanf "%d %d" (fun x y ->
    List.fold_left (fun acc (x, y, v) ->
        if x <= y then min acc (y - x + v) else acc) max_int
        [ (x, y, 0); (-x, y, 1); (x, -y, 1); (-x, -y, 2) ] |> Printf.printf "%d\n"
)