object Main extends App {
  import scala.math.sqrt
  
  val x = readInt
  
  var p = x-1
  var check = false
  while(!check) {
    p += 1
    check = (2 to sqrt(x).toInt).map{p % _ == 0}.forall{_ == false}
  }
  
  println(p)
}