let x = read_int ()
let f n = if n <= 1 then false else let rec f i = if i * i > n then true else if n mod i = 0 then false else f @@ i + 1 in f 2
let _ = for i = x to 100003 do if f i then (Printf.printf "%d\n" i; exit 0) done