import scala.io.StdIn.readInt

object Main extends App {
  val x = readInt()
  lazy val ys = 2 to (x / 2)
  
  def findPrime(x: Int): Int = {
    if (ys.exists(y => x % y == 0))
      findPrime(x + 1)
    else
      x
  }
  
  println(findPrime(x))
}