import scala.io.StdIn._

object Main extends App {


  val x = readInt()

  def solve(): Int = {
    val limit = 100010
    val primeNums = mkPrimeNums(limit)
    (x to limit).foreach { i =>
      if(primeNums(i)) return i
    }
    throw new Exception("can not find prime num")
  }

  def mkPrimeNums(limit: Int): Array[Boolean] = {
    val primeNums = Array.fill(limit+1)(true)
    (0 to Math.sqrt(limit).toInt).foldLeft(primeNums) { (acc, i) =>
      if(i == 0 || i == 1) acc.updated(i, false)
      else if(acc(i)) {
        val tmpAcc = acc
        for(j <- i * 2 to limit by i) tmpAcc(j) = false
        tmpAcc
      } else acc
    }
  }

  println(solve())

}

