fun main(args: Array<String>) {
    val x = readLine()!!.toInt()
    if (x == 2) {
        println(2)
        return
    }
    var list: MutableList<Int> = mutableListOf()
    val primes: MutableSet<Int> = mutableSetOf()
    for (i in 2 until x) {
       list.add(i)
    }

    do {
        val head = list.removeAt(0)
        primes.add(head)
        list = list.filter { it%head!=0 }.toMutableList()
    } while (head >= x)

    list.forEach { primes.add(it) }

    fun checkPrime(n: Int): Boolean {
        for (i in primes) {
            if (n%i==0) return false
        }
        return true
    }

    var res = x
    while (!checkPrime(res)) {
        res++
    }
    println(res)
}
