import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe
import           Debug.Trace

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

isPrime x | x < 2 = False
          | otherwise = let sx = ceiling $ sqrt $ fromIntegral x
                        in and [x `mod` i /= 0 | i <- [2..sx]]

solve n | isPrime n = n
        | otherwise = solve (n+1)

main = do
  x <- getInt
  let ans = solve x
  print ans