import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val x = sc.nextInt


  val res = (x to x + 1000).find(isPrime).get

  println(res)

  def isPrime(num: Int): Boolean = {
    num match {
      case 1 => false
      case 2 => true
      case x => (2 to Math.sqrt(x).toInt).forall(num % _ != 0 )
    }
  }
}