object Main extends App {
  val x = readInt
  
  var lst = (2 to x).toList
  var primeList:List[Int] = Nil
  
  while (lst != Nil) {
    val h = lst.head
    primeList ::= h
    lst = lst.tail.filter{_ % h != 0}
  }
  
  primeList = primeList.reverse
  
  var check = false
  
  if (x == primeList.last) println(x) 
  else {
    var p = x
    while(!check) {
      p += 1
      check = primeList.map{p % _ == 0}.forall{_ == false}
    }
    println(p)
  }
}