main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve 2 = 2
solve x | odd x     = solve' x
        | otherwise = solve' $ x + 1

solve' :: Int -> Int
solve' x | isPrime x = x
         | otherwise = solve' $ x + 2

isPrime :: Int -> Bool
isPrime x | x < 2     = False
          | otherwise = go 2 x
 where
  go x y | x * x > y      = True
         | y `mod` x == 0 = False
         | otherwise      = go (x + 1) y
