
object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  var x = sc.nextInt()
  val num = Stream.iterate(x){x => x + 1}
  val ans = num.filter(x => !calc(x)).head
  println(ans)

  def calc(n: Int): Boolean = {
    for (i <- 2 until n) {
      if (n % i == 0) {
        return true
      }
    }
    false
  }
}