let () = let a, b = Scanf.scanf "%d %d " (fun a b -> a, b) in Printf.printf "%d\n" (if a < b then a - 1 else 2000000000 - a)