fun main(args: Array<String>) = println(run {
    var x = readLine()!!.toInt()

    val primes = eratosthenes(100100)
    while (primes.binarySearch(x) < 0) ++x
    x
})

fun eratosthenes(n: Int): List<Int> {
    val sqrtN = Math.sqrt(n.toDouble()).toInt()
    val prime = mutableListOf<Int>()
    var list = (2..n).toList()
    while (list.first() < sqrtN) {
        val p = list.first()
        prime += p
        list = list.filter { it % p != 0 }
    }
    return prime + list
}