module Main where
import           Control.Applicative
 
 
main :: IO ()
main = do
    input <- read <$> getLine
    putStrLn . show $ nextPrime input
 
 
isPrime :: Int -> Bool
isPrime x | x < 2     = False
          | otherwise = prime (2 : [3, 4 .. (x - 1)])
  where
    prime :: [Int] -> Bool
    prime [] = True
    prime (t : next) | x `mod` t == 0 = False
                     | otherwise      = prime next
 
nextPrime :: Int -> Int
nextPrime n = if isPrime (n + 1) then n + 1 else nextPrime (n + 1)