function main(input) {
    let [totalPrice , length] = input.split("\n")[0].split(" ").map( v => Number(v));
    
    const list = JSON.parse(JSON.stringify(input.split("\n")[1].split(" ").map(v => Number(v))));
    const hateNumbers = { list, length };
    // const favoriteNumber = Array.from({ length: 10 }, (v, i) => i);
    // favoriteNumber.filter(v => hateNumbers.list.includes(v) ? false : true)

    const matches = new RegExp(`[${hateNumbers.list.join("")}]`);
    while (matches.test(totalPrice.toString())) {
        totalPrice++;
    }
    console.log('totalPrice', totalPrice);

}


// let input = "1000 8" + '\n' +
//     "1 3 4 5 6 7 8 9";
// main(input);
main(require("fs").readFileSync("/dev/stdin","utf8"));
  