main = do
  x <- readLn :: IO Int
  print $ genPrime x

genPrime :: Int -> Int
genPrime x
  | isPrime x 2 = x
  | otherwise = genPrime (x+1)

isPrime :: Int -> Int -> Bool
isPrime x i 
  | i*i > x = True
  | x `mod` i == 0 = False
  | otherwise = isPrime x (i+1)