import Data.List

main = do
  x <- readLn :: IO Integer
  putStrLn $ show $ head $ filter (>= x) $ primes

primes :: [Integer]
primes = 2 : [ n | n <- [3..], head (primeFactors n) == n ]

primeFactors :: Integer -> [Integer]
primeFactors n = factors n primes
    where factors n ps@(p:qs)
              | n < 2        = []
              | n < p^2      = [n]
              | mod n p == 0 = p : factors (div n p) ps
              | otherwise    = factors n qs
