let rec fix f x = f (fix f) x
let isprime x =
  fix (fun f d -> if d * d > x then true else x mod d <> 0 && f (d+1)) 2

let () =
  Scanf.scanf "%d" @@ fun x ->
  fix (fun f v -> if isprime v then v else f (v+1)) x
  |> Printf.printf "%d\n"
