import scala.io.StdIn._

object Main extends App {


  val x = readInt()

  def solve(): Int = {
    val limit = 100010
    val primeNums = Array.fill(limit+1)(true)
    (0 to Math.sqrt(limit).toInt).foreach { i =>
      if(i == 0 || i == 1) primeNums(i) = false
      else if(primeNums(i)) {
        for(j <- i * 2 to limit by i) primeNums(j) = false
      }
    }
    (x to limit).foreach { i =>
      if(primeNums(i)) return i
    }
    0
  }

  println(solve())

}

