let js = Array.make 10 true
let rec f n = n = 0 || js.(n mod 10) && f (n / 10)
let _ = Scanf.scanf " %d %d" @@ fun n k -> for _ = 1 to k do js.(Scanf.scanf " %d" (+) 0) <- false done; for i = n to 100000 do if f i then (Printf.printf "%d\n" i; exit 0) done