import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    x <- getInt
    print $ solve x
    
solve x = head . filter (x <=) $ sieve [2..]

sieve (x : xs) = x : sieve [y | y <- xs, y `mod` x /= 0]