import java.util.*

fun main(args: Array<String>) {
    val X = readLine()!!.toInt()
    println(Sieve.nextPrime(X))
}

object Sieve {
    private val N = 1000000
    private val primes: Array<Int>

    init {
        val que = ArrayDeque<Int>()
        val sieve = BooleanArray(N + 1) { true }
        sieve[0] = false
        sieve[1] = false
        for (i in 2..N) {
            if (!sieve[i]) continue
            que.push(i)
            for (j in (i * 2)..N step i) {
                sieve[j] = false
            }
        }
        primes = que.toTypedArray()
    }

    fun nextPrime(n: Int) = primes.last { it >= n }
}