object Main extends App {
  @scala.annotation.tailrec
  def isPrime(x: Int, count: Int): Boolean =
    if (x % count == 0) false
    else if (x < count * count) true
    else isPrime(x, count + 1)
  @scala.annotation.tailrec
  def loop(i: Int): Int = if(i == 2) 2 else if (isPrime(i, 2)) i else loop(i + 1)
  val sc = new java.util.Scanner(System.in)
  val x = sc.nextInt()
  println(loop(x))
}
