Problem:
 Score : 300 points    Problem Statement Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K .  She is shopping, and now paying at the cashier.
Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.      Constraints  1 ≦ N < 10000  1 ≦ K < 10  0 ≦ D_1 < D_2 < … < D_K≦9  \{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}         Input The input is given from Standard Input in the following format:  N  K  D_1  D_2 … D_K       Output Print the amount of money that Iroha will hand to the cashier.        Sample Input 1 1000 8
1 3 4 5 6 7 8 9      Sample Output 1 2000  She dislikes all digits except 0 and 2 .  The smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2 , is 2000 .       Sample Input 2 9999 1
0      Sample Output 2 9999

Solution (Python):
N,K=map(int,input().split())
D=list(input().split())
 
while True:
    for s in str(N):
        if s in D:
            N+=1
            break
    else:
        print(N)
        exit()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N,K=map(int,input().split())
    N= str(N)

    S={i for i in range(10)}
    D=set(map(int,input().split()))
    D=S-D

    def search(N):
        for i in range(len(N)):
            if int(N[i]) not in D:
                return True
            elif i==len(N)-1:
                return False

    while True:
        if search(N) ==True:
            N=str(int(N)+1)
        else:
            print(N)
            break









resolve()

Solution (Python):


n,k = map(int,input().split())
s = str(n)
d = list(map(int,input().split()))
for i in range(n,100000):
    
    str_i = str(i)
    ok = 1
    for j in str_i:
        if int(j) in d:
            ok = 0
            break
    if ok:
        print(i)
        exit()

Solution (Python):
ans,k = map(int,input().split())
d = set(input().split())
f = True
while f:
    f = False
    for i in str(ans):
        if i in d:
            f = True
    if f:ans += 1
print(ans)

Solution (Python):
N,K=input().split()
nums = input().split()
cand = list(map(str,list(x for x in range(10))))
for num in nums:
  if num in cand:
    cand.remove(num)
work = []
if int(N) <= int(cand[-1]*len(N)):
  for i in range(len(N)):
    for c in cand:
      if int(N[i]) == int(c):
        work.append(c)
        break
      elif int(N[i]) < int(c):
        work.append(c)
        for j in range(i+1,len(N)):
          work.append(cand[0])
        print(''.join(work))
        exit()
else:
  if cand[0] != '0':
    work.append(cand[0])
  else:
    work.append(cand[1])
  for i in range(len(N)):
    work.append(cand[0])
print(''.join(work))

Solution (Python):
import sys

n,k=map(int,input().split())
d=list(map(int,input().split()))
count=0

for i in range(n,1000000000):
  for j in range(len(str(i))):
    if str(i)[j] in str(d):
      break
      
    else:
      count+=1
      
  if count==len(str(i)):
    print(i)
    sys.exit()
  count=0

Solution (Python):
N,K=map(int,input().split())
D=list(input().split())

while True:
    for s in str(N):
        if s in D:
            N+=1
            break
    else:
        print(N)
        exit()

Solution (Python):
from collections import deque

N,K=map(int,input().split())
D=list(map(int,input().split()))
like=list(range(1,10))
dislike0=False

for s in D:
    if s==0:
        dislike0=True
    else:
        like.remove(s)

like.sort()
q=deque(like)

if dislike0==False:
    like.insert(0,0)

while q:
    num=q.popleft()

    if num>=N:
        print(num)
        exit()
    for i in range(len(like)):
        q.append((int(str(num)+str(like[i]))))

Solution (Python):
n, k = map(int, input().split())
d = list(map(int, input().split()))

n_str = str(n)


l = list(({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(d)))



ans = n
found = False
while not found:
  found = True
  ans_str = str(ans)
  for i in range(len(ans_str)):
    if int(ans_str[i]) not in l:
      
      found = False
  ans +=1

ans -= 1

print(ans)

Solution (Python):

strs = []
n,k = map(int,input().split())
hates = list(input().split())

give = n

while(True):
  stri = str(give)
  hantei = True
  for hate in hates:
    if hate in stri:
      hantei = False
      break;
  if hantei:
    print(give)
    break;
  else:
    give = give + 1

Solution (Python):
import itertools
n,k = map(int,input().split())
unlike = list(map(int,input().split()))
like = []
for i in range(0,10):
    if not(i in unlike):
        like.append(i)
i = 1
ans = 0
while(i < 99):
    current = list(itertools.product(like,repeat=i))
    for j in range(len(current)):
        h = int("".join(map(str,(list(current[j])))))
        if n <= h:
            print(h)
            exit()
    i += 1

Solution (Python):
N,K=map(int,input().split())
D=list(map(int,input().split()))

n=[str(N)[i] for i in range(len(str(N)))]

for i in range(N,10*N+1):
  flag=True
  for j in range(len(str(i))):
    if(int(str(i)[j]) in D):
      flag=False
  if(flag==True):
    ans=i
    break
print(ans)

Solution (Python):
n, k = map(int, input().split())
d = set(input())

while set(str(n))&d:
    n += 1
print(n)

Solution (Python):
def checkN(N,D):
    for each in N:
        if each in D:
            return False
    return True
line1 = input().split(' ')
N = line1[0]
D = input().split(' ')
i = -1
while not checkN(N, D):
    N = str(int(N)+1)
    
print(N)

Solution (Python):
def solve(price, usable):
  ans = price
  usable_set = set(usable)
  while True:
    ans_set = {int(i) for i in list(str(ans))}
    if ans_set <= usable_set:
      return ans
    ans += 1

if __name__ == "__main__":
  n,k = map(int,input().split())
  d_list = [int(i) for i in input().split()]

  usable = [int(i) for i in range(10) if i not in d_list]
  print(solve(n, usable))

Solution (Python):
n,_=map(int,input().split())
s=set(input())
while s&set(str(n)): n+=1
print(n)

Solution (Python):
n,_=map(int,input().split())
s=set(input().split())
while s&set(str(n)): n+=1
print(n)

Solution (Python):
n,k=map(int,input().split())
l=input().split()
while 1:
  for i in str(n):
    if i in l: n+=1; break
  else: print(n); break

Solution (Python):
n,k = map(int,input().split())
d = input().split()

def judge(strn):
    for i in strn:
        if i in d: return 0
        else: continue
    return 1

while True:
    strn = str(n)
    if judge(strn): 
        print(strn)
        exit()
    else: n+=1

Solution (Python):
N,_=map(int, input().split())
D=input().rstrip().split()
n=N
while True:
	flag=False
	s=list(str(n))
	for i in s:
		if i in D:
			flag= True
			break
	if not flag:
		break
	n+=1
print(n)

Solution (Python):
N, K = map(int, input().split())
D = set(input().split())

for i in range(N, 100000):
    if not set(list(str(i))) & D:
        print(i)
        break

Solution (Python):
n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(1,100001):
    if i<n:
        continue
    num=str(i)
    ok=True
    for nn in num:
        if int(nn) in d:
            ok=False
            break
    if ok:
        print(i)
        exit(0)

Solution (Python):
N,K=map(int,input().split())
D=list(map(int,input().split()))

import re 
L=[0,1,2,3,4,5,6,7,8,9]
D=set(D)
L=set(L)
L_D =list(L-D)

while True:
    Value=N
    S_value=str(Value)
    for j in range(len(L_D)):
        S_value=re.sub('{}'.format(L_D[j]),'',S_value)
    if S_value=='':
        print('{}'.format(Value))
        exit(0)
    N+=1

Solution (Python):
n,k,*d=map(int,open(0).read().split())
while 1:
 for i in str(n):
  if int(i)in d: break
 else:print(n);break
 n+=1

Solution (Python):
n=int(input().split()[0]);d=set(input());print(min(i for i in range(n,99999)if not d&set(str(i))))

Solution (Python):
n = int(input().split()[0])
d = set(input())
for i in range(n, 999999):
    if not set(str(i)) & d:
        print(i)
        break

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = list(input())
a = set(a)
for ans in range(n,n+100000):
    tmp = str(ans)
    for i,t in enumerate(tmp):
        if t in a:
            break
    else:
        print(ans)
        break

Solution (Python):
n,k=map(int,input().split())
d=list(input())
while True:
    ns=str(n)
    for i in d:
        if i in ns:break
    else:
        print(ns)
        exit()
    n+=1

Solution (Python):
n,k=map(int,input().split())
d=list(map(int,input().split()))

num=[]
for i in range(10):
    if i not in d:
        num.append(i)

num.sort()
digit=len(str(n))
ns=str(n)

ans=''
cnt=0
while cnt<digit:

    for i in num:
        if int(ns[cnt])>i:continue
        if int(ns[cnt])==i:
            ans+=str(i)
            break
        else:
            ans+=str(i)+(digit-cnt-1)*str(num[0])
            cnt=digit
            break
    else:
        ans=str(num[0]) if num[0]!=0 else str(num[1])
        ans+=str(num[0])*digit
        cnt=digit
    cnt+=1
print(ans)

Solution (Python):
amount, num_cnt = map(int, input().split())
hate_list = input().split()

payment = 0
for i in range(amount, 100000):
    nums = set(list(str(i)))
    flg = False
    for j in nums:
        if j in hate_list:
            flg = True
            break
    if not flg:
        payment = i
        break

print(payment)

Solution (Python):
n,k=map(int,input().split())
d=list(map(int,input().split()))
possible=set()
for i in range(0,10):
    if i not in d:
        possible.add(str(i))
for i in range(n,100000):
    i=str(i)
    for j in i:
        if j not in possible:
            break
    else:
        print(i)
        exit()

Solution (Python):
n,k = map(int,input().split())
d = list(map(int,input().split()))
def ok(x):
    x = str(x)
    for i in range(len(x)):
        if int(x[i]) in d:
            return False
    return True
for i in range(n,10**5):
    if ok(i):
        print(i)
        break

Solution (Python):
n, k = map(int, input().split())
D = list(map(int, input().split()))

def valid(x):
    for xx in str(x):
        if int(xx) in D:
            return False
    return True

while True:
    if valid(n):
         print(n)
         break
    n += 1

Solution (Python):
N,_ = map(int, input().split())
D = set(input().split())

for i in range(10 ** 6):
    S = set(list(str(N)))
    if not D & S:
        break
    N += 1

print(N)

Solution (Python):
N, K = map(int, input().split())
D = set(list(input()))

for k in range(N, 20 * N):
    if len(set(list(str(k))) & D) == 0:
        print(k)
        exit()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, k = MAP()
d = LIST()
for i in range(n, n * 10):
    y = list(str(i))
    flag = True
    for j in d:
        if str(j) in y:
            flag = False
            break
    if flag:
        print(i)
        exit()

Solution (Python):
N,K=map(int, input().split())
D=set(input().split())

def check(x):
    for c in str(x):
        if c in D: return False
    return True

ans = N
while not check(ans): ans += 1
print(ans)

Solution (Python):
N, K = map(int, input().split())
A = set(input().split())

for i in range(100001):
    S = set(list(str(N)))
    if not A & S:
        ans = N
        break
    N += 1

print(N)

Solution (Python):
def solve():
    n,k = map(int,input().split())
    d = set(map(int,input().split()))
    for i in range(n,100000):
        s = map(int,str(i))
        flag = True
        for j in s:
            if j in d:
                flag = False
        if flag:
            print(i)
            return

if __name__ == "__main__":
    solve()

Solution (Python):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
d = set(map(int, input().split()))
for x in range(N, 10 ** 6):
  f = 1
  for y in str(x):
    if int(y) in d:
      f = 0
      break
  if f:
    print(x)
    exit(0)

Solution (Python):
N, K = [int(i) for i in input().split()]
D = set([i for i in input().split()])

while True:
    res = str(N)
    for v in D:
        if v in res:
            break
    else:
        print(res)
        quit()
    N += 1

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    D = {i for i in input().split()}
    ans = N
    while any(a in D for a in str(ans)):
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
D = list(map(int, input().split()))
D = set(D)

while True:
    s = list(str(n))
    flag = True
    for i in range(len(s)):
        if int(s[i]) in D:
            flag = False
    if flag:
        break
    else:
        n += 1
print(n)

Solution (Python):
import itertools

n, k = map(int, input().split())
d = input().split()

for i in itertools.count(n):
    for k in str(i):
        if k in d:
            break
    else:
        print(i)
        break

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    
    N, K = Scanner.map_int()
    D = Scanner.string().split(sep=' ')
    ans = N
    while True:
        for s in str(ans):
            if s in D:
                break
        else:
            print(ans)
            return
        ans += 1


if __name__ == "__main__":
    main()

Solution (Python):
N, K = list(map(int, input().split()))
D = set(input().split())
num = {str(i) for i in range(10)} - D

while True:
    if set(str(N)) <= num:
        ans = N
        break
    else:
        N += 1
print(ans)

Solution (Python):
N, K = map(int, input().split())
D = set(input().split())
ans = N
while not set(str(ans)).isdisjoint(D):
    ans += 1
print(ans)

Solution (Python):
N,K = map(int,input().split())
List = list(input().split())
Digit = ['0','1','2','3','4','5','6','7','8','9']
for item in List:
  if item in Digit:
    Digit.remove(item)
for i in range(N,10*N):
  if set(list(str(i))) <= set(Digit):
    print(i)
    exit()

Solution (Python):
n, k = map(int, input().split())
d = set(input().split())

nums = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
dd = d ^ nums

i = n
while True:
        if dd >= set(list(str(i))):
            print(i)
            exit()
        else:
            i += 1

Solution (Python):



def exist(target, array):
    for token in list(str(target)):
        if token in array:
            return True
    return False


n, _ = map(int, input().split())
d = input().split()

x = n
while True:
    if not exist(x, d):
        break
    x += 1

print(x)

Solution (Python):
N, K = map(int, input().split())
D = set(input().split())
ans = N
while not set(str(ans)).isdisjoint(D):
    ans += 1
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, K: int, D: "List[int]"):

    D = set([str(c) for c in D])
    for ans in range(N, 10*N):
        if set(str(ans)).isdisjoint(D):
            print(ans)
            return

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    D = [int(next(tokens)) for _ in range(K)]  
    solve(N, K, D)


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int,input().split())
alg = set([0,1,2,3,4,5,6,7,8,9])
numeros = set(map(int, input().split()))

def contem(num, numeros):
	
	for l in str(num):
		if int(l) in numeros:
			return False
	return True
	

target = n


while not contem(target,numeros):
	target += 1

print(target)

Solution (Python):
N, K = map(int, input().split())
D = {x for x in input().split()}

for i in range(N, 100000):
    l = set(list(str(i)))
    if len(l & D) == 0:
        print(i)
        break

Solution (Python):
n,k=map(int,input().split())
s=set(input().split())
while 1:
  if set(list(str(n)))&s:n+=1
  else:break
print(n)

Solution (Python):
n,k = map(int,input().split())
d = tuple(map(int, input().split()))
flug = 1
while flug:
    flug = 0
    n2 = list(map(int,str(n)))
    for i in n2:
        if i in d:
            n += 1
            flug = 1
            break
print(n)

Solution (Python):
n,k = map(int,input().split())
d = list(map(int,input().split()))

for i in range(1000000):
    if i < n:
        continue
    i1 = str(i)
    flag = True
    for j in range(len(i1)):
        if not flag:
            break
        i2 = int(i1[j])
        if i2 in d:
            flag = False
    if not flag:
        continue
    print(i)
    break

Solution (Python):
n, k = map(int, input().split())
d = list(map(str, input().split()))
possible = [str(i) for i in range(10) if str(i) not in d]
for i in range(n,10**5):
    for j in str(i):
        if j not in possible:
            break
    else:
        print(i)
        exit()

Solution (Python):
import itertools

n, k = map(int, input().split())
d = list(map(int, input().split()))
use = [i for i in range(10) if not i in d]

p = list(itertools.product(use, repeat=len(str(n))))

ans = float('inf')
for i in p:
    numlist = []
    if i[0] != 0:
        for g in range(len(str(n))):
            numlist.append(str(i[g]))
        num = int(''.join(numlist))
        if num>=n:
            ans=min(ans,num)

if ans==float('inf'):
    if min(use)==0:
        print(int(str(use[1])+"0"*len(str(n))))
    else:
        print(int(str(min(use))*(len(str(n))+1)))
else:
    print(ans)

Solution (Python):
N,K = [int(i) for i in input().split()]
D = sorted([int(i) for i in input().split()],reverse=True)

def is_ok(x):
  while x!=0:
    if x%10 in D:
      return False

    x //=10

  return True

while True:
  if is_ok(N):
    print(N)
    break
  N+=1

Solution (Python):
n, k = map(int, input().split())
d = [ int(x) for x in input().split() ]

def is_ok(x):
    while x != 0:
        if x % 10 in d:
            return False
        x //= 10
    return True

money = n
while True:
    if is_ok(n):
        print(n)
        break
    n += 1

Solution (Python):
import functools

n,k=map(int,input().split())
d=list(map(int,input().split()))

for i in range(n,n*11):
    count=0
    l = [int(x) for x in list(str(i))]
    for j in l:
        
        if j  not in d :
            count+=1
    if count==len(l):
        print( int(functools.reduce(lambda x, y: x + y, [str(x) for x in l])))
        exit()

Solution (Python):
numbers = {str(i) for i in range(10)}
N, K = map(int, input().split())
D = list(map(str, input().split()))
D = set(D)
available = numbers - D

for i in range(N, 100000):
  nums = set(str(i))
  if nums <= available:
    print(i)
    break

Solution (Python):
N, K = map(int, input().split())
List = list(map(int, input().split()))

price = N - 1

while True:
    flag = True
    price += 1
    price_str = str(price)
    for num in str(price_str):
        if int(num) in List:
            flag = False
            
    if flag == True:
        print(price)
        break

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, k = MAP()
d = set(S_LIST())
m = n
while True:
    if len(set(str(m)) & d) == 0:
        print(m)
        exit()
    m += 1

Solution (Python):
n,k = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]

for x in range(n, 100000):
    ans = 100000
    tmp = True
    for y in str(x):
        if int(y) in d:
            tmp = False
            break
    if tmp:
        ans = min(ans,x)
        break

print(ans)

Solution (Python):
from sys import stdin
from operator import itemgetter


N, K = [int(x) for x in stdin.readline().rstrip().split()]
d = stdin.readline().rstrip()
D = d.replace(' ','')
D_list = [D[i] for i in range(0, len(D), 1)]
price = N
buy = False

while buy == False:
    price_str = str(price)
    price_list = [price_str[i] for i in range(0, len(price_str), 1)]
    price_kaburi = list(set(price_list)) 
    check = D_list + price_kaburi
    check_list = list(set(check))
    if len(check) == len(check_list):
        print(price)
        break
    else:
        price += 1

Solution (Python):
N,K=map(int,input().split())
D=list(input().split())
D.insert(0,0)
n=0
while True:
    n+=1
    ok=True
    for i in list(str(n)):
        if i in D:
            ok=False
            break
    if ok and N<=n:
        print(n)
        break

Solution (Python):
n,k=map(int,input().split())
d=list(input().split())

while True:
    ok = True 
    for x in d:
        if x in str(n):
            ok = False
            break
    if ok:
        print(n)
        exit()
    n += 1

Solution (Python):
n,k=map(int,input().split())
D=set(map(int,input().split()))
for i in range(n,10**5+10): 
  S=list(str(i))
  a=0
  for j in range(len(S)):
    if int(S[j]) in D:
      a=1
      break
  if a==0:
    print(i)
    break

Solution (Python):
n, k = map(int, input().split())
d = list(input().split())

while True:
    ok = True
    for x in d:
        if x in str(n):
            ok = False
            break
    if ok:
        print(n)
        exit()
    n += 1

Solution (Python):
n, k = map(int,input().split())
l = set(map(str, input().split()))
x = list(set(['0','1','2','3','4','5','6','7','8','9']) - l)
y = len(str(n))

from itertools import product
z = list(product(x, repeat = y))
z += list(product(x, repeat = y + 1))

for i in range(len(z)):
    z[i] = int(''.join(z[i]))

z.sort()
for j in z:
    if j >= n:
        print(j)
        break

Solution (Python):
N,K = map(int,input().split())
D = list(map(str,input().split()))
ind_f = lambda x:x in D
for i in range(N,10*N):
  i_li = list(str(i))
  if  not any(map(ind_f, i_li)):
    print(i)
    break

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key



__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x

    

if __name__ == '__main__':
    N, K = mulinputs()
    *ds, = mulinputs()

    for n in range(N, 100000):
        nn = n
        is_ok = True
        while nn >= 1:
            num = nn % 10
            nn //= 10
            for dd in ds:
                if dd == num:
                    is_ok = False
                    break
            if not is_ok:
                break
        if is_ok:
            print(n)
            exit()

Solution (Python):
N, K = map(int, input().split())
numbers = set(input().split())
num = N

while True:
  l = set([s for s in str(num)])
  if l.isdisjoint(numbers):
    print(num)
    break
  num += 1

Solution (Python):
n, k = map(int, input().split())
dlist = list(map(int, input().split()))



res = []

digit = len(str(n))

while True:
    ok = True
    for i in range(0, len(str(n))):
        num = n // 10 ** (i) % 10
        if num in dlist:
            ok = False
    if ok:
        print(n)
        exit(0)
    n += 1

Solution (Python):

n, k = map(int, input().split())
d = set(map(int, input().split()))
d_ = list({i for i in range(0, 10)} - d)
inf = 10 ** 7

def dfs(frm, cur):
    if frm == cur == 0:
        return inf
    if cur >= n:
        return cur
    
    x = 10 ** 7
    for k in d_:
        x = min(x, dfs(cur, cur * 10 + k))
        
    return x

print(dfs(-1, 0))

Solution (Python):
from collections import deque

N, K = map(int, input().split())
D = input().split()

nums = list("0123456789")
for d in D:
    nums.remove(d)


def dfs(N, nums):
    ans = 10 ** 9
    if "0" in nums:
        queue = deque(nums[1:])
    else:
        queue = deque(nums)

    while queue:
        tmp = queue.pop()
        if int(tmp) >= N:
            if int(tmp) < ans:
                ans = int(tmp)
        else:
            for n in nums:
                queue.append(tmp + n)

    return ans


print(dfs(N, nums))

Solution (Python):
n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(n,n*10+1):
  N=list(str(i))
  for j in range(len(N)):
    N[j]=int(N[j])
  N=set(N)
  d=set(d)
  if N.isdisjoint(d):
    print(i)
    exit()

Solution (Python):
N,K = map(int, input().split())
Ds = list(map(int, input().split()))

able = []
for i in range(10):
    if i in Ds:continue
    able.append(i)


sN = str(N)
n = len(sN)
m = able[0] 


if int(sN[0]) > max(able):
    if m == 0:
        ans = str(able[1]) + str(able[0]) * n
    else:
        ans = str(able[0]) * (n+1)
    print(ans)
    exit()
prev = -1
flg = True 
ans = ""
for i,s in enumerate(sN):
    flg2 = False
    if flg:
        for j,a in enumerate(able):
            if int(s) < a:
                ans += str(a)
                flg = False
                flg2 = True
                break
            if int(s) == a:
                ans += str(a)
                flg = True
                flg2 = True
                break
        if not flg2:
            if prev == len(able)-1:
                if m == 0:
                    ans = str(able[1]) + str(able[0]) * n
                else:
                    ans = str(able[0]) * (n+1)
                print(ans)
                exit() 
            ans = ans[:-1]
            ans += str(able[prev+1]) + str(m)
            flg = False
    else:
        ans += str(m)    
    prev = j
    

print(ans)

Solution (Python):
N,K = map(int,input().split())
d = set(map(str,input().split()))
OK = {str(i) for i in range(10)} - d


for i in range(N,100000):
  if set(str(i)) <= OK:
    print(i)
    exit()