fun main(args: Array<String>) = println(run {
    var x = readLine()!!.toLong()
    
    while (!isPrime(x)) ++x
    x
})

fun isPrime(x: Long): Boolean {
    val sqrtX = Math.sqrt(x.toDouble()).toLong()
    return (2..sqrtX).all { x % it != 0L }
}