object Main {
  def main(args:Array[String]) {
    val X = readLine().toInt
    val max = 100003
    var num = List.range(2, 100004)
    var prime = List[Int]()

    var n = num(0)
    while(n <= math.sqrt(max)) {
      prime = prime :+ n
      num = num.filter(_ % n != 0)
      n = num(0)
    }
    prime  = prime ::: num
    var ans = 0
    ans = prime.filter(_ > X)(0)
    println(ans)
  }
}
