import io.StdIn._
object Main extends App {
  val primes = Stream.cons(2, Stream.from(3, 2) filter { isPrime(_) })
  def isPrime(i: Int): Boolean = {
    (i > 1) && primes.takeWhile(_ <= math.sqrt(i)).forall(i % _ != 0)
  }

  var n = readInt
  while(!isPrime(n)) {
    n = n + 1
  }
  println(n)
}
