object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in(0).split(' ').map(_.toInt)
  val X = ls(0)
  val tbl = (0 to 200001).map(_ => false).toArray
  //tbl(2) = false
  //tbl(3) = true
  //tbl(5) = true
  
  var i = 2
  val End = X*2
  while(i<End){
    var j = i*2
    while(j<End){
      tbl(j) = true
      j += i
    }
    i += 1
  }
  
  //(0 to X*2).foreach{i => println(i, tbl(i)) }
  
  var k = X
  var found = false
  do{
    if(!tbl(k))
      found = true
    else k += 1
  }while(!found)
  println(k)
}
