object Main extends App {
	val x = io.StdIn.readLine.toInt
	
	def e(input: Seq[Int]): Seq[Int] = input match {
		case Seq() => Seq()
		case head +: tail => head +: e(tail filter (_ % head != 0))
	}
	
	val primes = e(2 to Math.sqrt(x).toInt)
	
	var n = x + 1
	while (primes.filter(n % _ == 0).nonEmpty) n += 1;
	
	println(n)
}