object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt

  var ans = 0
  while (ans == 0) {
    if(isPrime2(n))ans = n
    n += 1
  }
  println(ans)

  def isPrime(x: Int): Boolean = {
    var result = true
    if(x > 1) {
      for(i <- 2 until x) {
        if(x % i == 0) {
          result = false
        }
      }
    }else {
      result = false
    }
    result
  }
  def isPrime2(x: Int): Boolean = {
    var result = true
    if(x > 1) {
      for(i <- 2 until math.sqrt(x).toInt) {
        if(x % i == 0) {
          result = false
        }
      }
    }else {
      result = false
    }
    result
  }
}
