import scala.io.StdIn._

object Main extends App {


  val x = readInt()

  def solve(): Int = {
    var ans = x
    while(!isPrime(ans)) ans += 1
    ans
  }

  def isPrime(num: Int): Boolean = {
    if(num <= 1) false
    else if(num == 2) true
    else (2 until num).forall(num % _ != 0)
  }

  println(solve())

}

