object Main extends App {
  val x = readLine.toInt
  
  def check(n:Int): Int = {
    val sqrt = math.sqrt(n).toInt
    val notPrime = (2 +: (3 to sqrt).filter(_ % 2 == 1)).exists(n % _ == 0)
    if (n == 2) n
    else if (notPrime) check(n+1)
    else n
  }
  
  println(check(x))
}