import Data.List

main :: IO ()
main = do
  l1 <- getLine
  let x = read l1 :: Int
  print $ head $ dropWhile (<x) primes

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

primes' :: [Int] -> [Int]
primes' (p:l) = ps' ++ primes' l''
  where (ps, l') = span (<p*p) l
        ps' = p:ps
        l'' = filter (\x -> all (\p -> x `mod` p /= 0) ps') l'