fun main() {
    var (x, y) = readLine()!!.split(" ").map { it.toInt() }
    
    if (y == 0) {
            println(x)
        }
    else {
        var arr = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
        var ind = arr.indexOf(x)
        var i = 0
        var j = 0

        while(true) {
            var a = x + (i--)
            var b = x + (j++)
            if (a !in arr) {
                println(a)
                break
            }
            if (b !in arr) {
                println(b)
                break
            }
        }
    }
}