import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def prime(n: Int, primes: Seq[Int]) = primes.forall(p => n % p != 0)

  def solve(sc: Scanner): String = {
    val X = sc.nextInt
    var primes = Seq(2, 3, 5, 7, 11, 13)
    for (i <- 17 to 100003 by 2) {
      if (prime(i, primes)) {
        primes = primes :+ i
      }
    }
    primes.find(_ >= X).head.toString
  }
}
