import io.StdIn._

object Main extends App {
  val n = readInt

  require(2 <= n && n <= 100000)

  def isPrime(n: Int): Boolean = (2 until n).toList.forall(n % _ != 0)

  def minPrime(n: Int): Option[Int] = (n to 200000).find(isPrime)

  minPrime(n).map(println)
}
