fun main(arr:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val numbers = readLine()!!.split(" ").map { it[0] }
    for(i in (n..n*100)) {
        if(i.toString().all { !numbers.contains(it) }) {
            println(i)
            return
        }
    }
}