isPrime :: Int -> Bool
isPrime num = null(filter (\x -> num `mod` x == 0) [2..floor(sqrt(fromIntegral num))])
 
main = do
    [x] <- map read . words <$> getLine
    let allList = [2..2*x]
    let primeList = [a | a <- allList, isPrime a ]
    let ans = head [a | a <- primeList, a >= x]
    putStrLn $ show ans