main :: IO ()
main = do
  x <- readLn
  print $ solve x

solve :: Int -> Int
solve x = head $ filter isPrime [x .. ]

isPrime :: Int -> Bool
isPrime x = all (\n -> x `mod` n /= 0) [2 .. y]
  where y = floor $ (sqrt (fromIntegral x) :: Double)
