object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val input = sc.nextInt()

    val result =
      if (input == 2) {
        // dirty...
        2
      } else {
        nextPrime(input)
      }

    println(result.toString)
  }

  @scala.annotation.tailrec
  def nextPrime(num: Int): Int = {
    val isPrime =
      (2.to(math.ceil(math.sqrt(num)).toInt))
        .forall(value => num % value != 0)
    if (isPrime) {
      num
    } else {
      nextPrime(num + 1)
    }
  }
}
