import java.io._
import java.util.StringTokenizer
import java.math.BigInteger

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val X = new BigInteger(in.next())
  println(X.add(new BigInteger("-1")).nextProbablePrime)
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
