import scala.io.{StdIn => in}

object Main extends App {

  val prime = Array.ofDim[Boolean](200001)
  for(i <- 2 to 200000) prime(i) = true

  for(i <- 2L to 200000L if prime(i.toInt)){
    for(j <- (i * i) to 200000L by i) {
      prime(j.toInt) = false 
    }
  }
  val x = in.readLine.toInt
  val ans = (x to 200000).filter(prime(_)).head
  println(ans)
}