import scala.math

object Main extends App{
    def isPrime(n: Int): Boolean = {
        if(n == 2) true
        else if(n == 1 || n % 2 == 0) false
        else(3 to math.sqrt(n).toInt).forall(n % _ != 0)
    }

    var x = io.StdIn.readLine.toInt
    while(isPrime(x) == false) x += 1
    println(x)
}