main :: IO ()
main = do
  x <- readLn
  print $ solve x

solve :: Int -> Int
solve x = head $ dropWhile (< x) primes

primes :: [Int]
primes = sieve [2..]

sieve :: [Int] -> [Int]
sieve (p:xs) = p : filter (\x -> x `mod` p > 0) xs