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-----
1000 8
1 3 4 5 6 7 8 9

-----Sample Output-----
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.
[{"code": "import itertools\n\ndef cal(N, target_num, keta):\n    answer = float('inf')\n    for p in itertools.product(target_num, repeat=keta):\n        temp = 0\n        for i, num in enumerate(p):\n            temp += num * 10**i\n            \n        if temp >= N:\n            answer = min(answer, temp)\n\n    return answer\n\ndef __starting_point():\n    N, K = map(int, input().split()) # N\u5186\u306e\u54c1\u7269\u3001K\u500b\u306e\u5acc\u3044\u306a\u6570\u5b57\n    D = set(list(map(int, input().split()))) # \u5acc\u3044\u306a\u6570\u5b57\u306e\u30ea\u30b9\u30c8\n    base = set(range(10))\n\n    target_num = base - D\n    keta = len(str(N))\n\n    answer = min(cal(N, target_num, keta), cal(N, target_num, keta+1))\n\n    print(answer)\n__starting_point()", "passed": true, "time": 0.33, "memory": 14132.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nunlike_list = set(map(str, input().split()))\n\ndef judge(num):\n    for i in str(num):\n        if i in unlike_list:\n            return False\n    return True\n\nans = False\nwhile not ans:\n    if judge(N):\n        ans = True\n    else:\n        N += 1\n\nprint(N)", "passed": true, "time": 0.15, "memory": 14096.0, "status": "done"}, {"code": "n, k = list(map(int,input().split()))\nd = list(map(int,input().split()))\n\nwhile n < 10**5:\n    x = str(n)\n    if all(int(i) not in d for i in x):\n        print(n)\n        return\n    n += 1\n", "passed": true, "time": 1.64, "memory": 14212.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nd = list(input().split())\nans = n\nfind = False\nwhile find == False:\n    p = str(ans)\n    find = True\n    for i in range(len(p)):\n        if p[i] in d:\n            find = False\n            break\n    if find == False:\n        ans += 1\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "import sys\n\nN,K=list(map(int,input().split()))\nD=list(map(int,input().split()))\n\n\nwhile True:\n  for x in [int(n) for n in str(N)]:\n    if x in D:\n      break\n  else:\n    print(N)\n    return\n  N+=1\n", "passed": true, "time": 0.21, "memory": 14252.0, "status": "done"}, {"code": "total, k = list(map(int, input().split()))\n\nd = list(map(int, input().split()))\n\ndef total_to_digits(total):\n    return list(map(int, list(str(total))))\n\ndef find_lowest_denomination(total, d):\n    res = None\n    for i in range(total, 99999):\n        digits = list(total_to_digits(i))\n        if not (set(digits) & set(d)):\n            print(i)\n            return\n\n\nfind_lowest_denomination(total, d)\n", "passed": true, "time": 0.15, "memory": 14088.0, "status": "done"}, {"code": "n, k = list(map(int,input().split()))\na = list(map(str,input().split()))\n\n\nwhile True:\n    \n    for j in str(n):\n        \n        if j in a:\n            break\n    else:\n        break\n    n += 1        \n    \nprint(n)", "passed": true, "time": 0.38, "memory": 14280.0, "status": "done"}, {"code": "def dfs(A: list):\n    if len(A) > len(str(n))+1:\n        return\n    if len(A) and (x := int(\"\".join(A))) >= n and ans[0] > x:\n        ans[0] = x\n        return\n\n    for v in d:\n        if v == \"0\" and len(A) == 0:\n            next\n        A.append(v)\n        dfs(A)\n        A.pop()\n\n\nn, k = list(map(int, input().split()))\nd = sorted(list(set([str(i) for i in range(10)]) - set(input().split())))\nans = [10**10]\ndfs([])\nprint((ans[0]))\n", "passed": true, "time": 0.48, "memory": 14324.0, "status": "done"}, {"code": "n, k= input().split()\nl = list(map(int,input().split()))\ncheckNum=[i for i in range(11)]\n\ndef find(x):\n    while x!=checkNum[x]:\n        checkNum[x]=checkNum[checkNum[x]]\n        x=checkNum[x]\n    return x\n\nfor i in l:\n    checkNum[find(i)]=checkNum[find(i+1)]\n\nfin=\"\"\nfor i in range(len(n)):\n    first=int(n[i])\n    k=find(first)\n    if k==first:\n        fin+=str(k)\n    else:\n        if k!=10:\n            fin=str(k)+str(find(0))*(len(n)-i-1)\n        else:\n            fin=str(find(1))+str(find(0))*len(n)\n        break\n\nprint(fin)\n", "passed": true, "time": 0.14, "memory": 14408.0, "status": "done"}, {"code": "N,K=list(map(int,input().split()))\nD=[int(x) for x in input().split()]\nD=set(D)\nkouho=N\nwhile(1):\n    lenkouho=len(str(kouho))\n    flag=1\n    for i in range(lenkouho):\n        if int(str(kouho)[i]) in D:\n            flag=0\n    if flag==1:\n        print(kouho)\n        break\n    kouho+=1\n", "passed": true, "time": 1.66, "memory": 14276.0, "status": "done"}, {"code": "#\n# abc042 c\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"1000 8\n1 3 4 5 6 7 8 9\"\"\"\n        output = \"\"\"2000\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"9999 1\n0\"\"\"\n        output = \"\"\"9999\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N, K = list(map(int, input().split()))\n    D = list(input().split())\n\n    for i in range(N, 10*N+1):\n        for d in D:\n            if str(i).count(d) != 0:\n                break\n        else:\n            print(i)\n            break\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.16, "memory": 14360.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nD = list(map(int, input().split()))\nnum = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\nnum = str(list(set(num) ^ set(D)))\n\nans = str(N)\nclear = 0\n\nwhile clear == 0:\n    for i in range(len(ans)):\n        if not ans[i] in num:\n            break\n        if i == len(ans) - 1:\n            clear += 1  \n    ans = str(int(ans) + 1)\n\nprint(int(ans) - 1)", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nD = list(input().split())\n\nwhile True:\n    n = str(N)\n    for i in range(K):\n        f = 0\n        if D[i] in n:\n            N += 1\n            f = 1\n            break\n    if f == 0:\n        break\n\nprint(N)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "#\u5024\u6bb5\u3001\u5acc\u3044\u306a\u6570\u5b57\u306e\u6570\nN, K = map(int, input().split())\n#\u5acc\u3044\u306a\u6570\u5b57\nhate_num = list(map(int, input().split()))\n#\u30eb\u30fc\u30d7\u7528\ni = N\n\nwhile 1:\n    #\u652f\u6255\u3046\u91d1\u984d\u306b\u5165\u3063\u3066\u3044\u308b\u6570\u5b57\u306e\u629c\u304d\u51fa\u3057\n    ans = list({int(i) for i in list(str(i))})\n    #\u652f\u6255\u3046\u91d1\u984d\u306b\u5acc\u3044\u306a\u6570\u5b57\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\n    for j in ans:\n        #\u5acc\u3044\u306a\u6570\u5b57\u304c\u3042\u3063\u305f\u6642\n        if j in hate_num: \n            break\n    #\u5acc\u3044\u306a\u6570\u5b57\u304c\u306a\u304b\u3063\u305f\u6642\n    else:\n        print(i)\n        break\n    i += 1", "passed": true, "time": 0.22, "memory": 14224.0, "status": "done"}, {"code": "n, k = input().split()\nd = list(map(int, input().split()))\n\na = []\n\nfor i in range(10):\n    if i not in d:\n        a.append(i)\n\nn = list(map(int, list(n)))\n\nfor i in range(len(n)):\n    if n[i] in d:\n        ind = i\n\n        done = False\n        while not done:\n            for j in range(n[ind]+1, 10):\n                if j in a:\n                    n[ind] = j\n                    done = True\n                    break\n\n            if not done:\n                ind -= 1\n\n                if ind < 0:\n                    n.insert(0, a[1] if a[0] == 0 else a[0])\n                    ind = 0\n                    done = True\n\n        for j in range(ind+1, len(n)):\n            n[j] = a[0]\n\n        break\n\nprint(\"\".join(list(map(str, n))))", "passed": true, "time": 0.14, "memory": 14336.0, "status": "done"}, {"code": "n,k = list(map(int,input().split()))\nif k == 0:\n  print(n)\n  return\ndislike = list(input().split())\n \nans = n-1\nflag = 1\nwhile flag == 1:\n  ans+=1\n  flag = 0\n  for i in str(ans):\n    if i in dislike:\n      flag = 1\n      break\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14140.0, "status": "done"}, {"code": "def testa(n,d):\n    for i in d:\n        if str(i) in str(n): return 0\n    return 1\n\nn,k = [int(i) for i in input().split()]\nd = [int(i) for i in input().split()]\n\nwhile not testa(n,d): n+=1\nprint(n)\n", "passed": true, "time": 0.21, "memory": 14080.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nbl = set(input().split())\n\nwhile True:\n  if len(set(str(N)) & bl) != 0:\n    N += 1\n  else:\n    print(N)\n    break", "passed": true, "time": 0.24, "memory": 14048.0, "status": "done"}, {"code": "N, K = list(map(int,input().split()))\nD = set(input().split())\n\nfor k in range(N,10**9):\n    f = 1\n    for e in str(k):\n        if e in D:\n            f = 0\n            break\n    if f == 1:\n        print(k)\n        return\n", "passed": true, "time": 0.97, "memory": 14292.0, "status": "done"}, {"code": "def dfs(i,num_str):\n    nonlocal ans_list\n    if i==len(str(n)):\n        ans_list.append(int(num_str))\n        if len(num_list)==1:\n            ans_list.append(int(num_list[0]+num_str))\n        else:\n            if num_list[0]=='0':\n                ans_list.append(int(num_list[1]+num_str))\n            else:    \n                ans_list.append(int(num_list[0]+num_str))\n        return\n    else:\n        for j in num_list:\n            dfs(i+1,num_str+j)\n\nn,k = map(int,input().split())\nd = list(map(int,input().split()))\n\nans_list = []\nnum_list = []\nfor i in range(10):\n    if i not in d:\n        num_list.append(str(i))\n        \n#print(num_list)\n\ndfs(0,'')\nsort_list = sorted(ans_list)\n#print(sort_list[10:])\n\nfor i in sort_list:\n    if n<=i:\n        print(int(i))\n        break", "passed": true, "time": 0.15, "memory": 14240.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nD = set(input())\nfor i in range(n, 10**5):\n  if set(str(i)) & D == set():\n    print(i)\n    return", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "#\u5024\u6bb5\u3001\u5acc\u3044\u306a\u6570\u5b57\u306e\u6570\nN, K = map(int, input().split())\n#\u5acc\u3044\u306a\u6570\u5b57\nhate_num = list(map(int, input().split()))\n#\u30eb\u30fc\u30d7\u7528\ni = N\n\nwhile 1:\n    #\u652f\u6255\u3046\u91d1\u984d\u306b\u5165\u3063\u3066\u3044\u308b\u6570\u5b57\u306e\u629c\u304d\u51fa\u3057\n    ans = list({int(x) for x in list(str(i))})\n    #\u652f\u6255\u3046\u91d1\u984d\u306b\u5acc\u3044\u306a\u6570\u5b57\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\n    for j in ans:\n        #\u5acc\u3044\u306a\u6570\u5b57\u304c\u3042\u3063\u305f\u6642\n        if j in hate_num: \n            break\n    #\u5acc\u3044\u306a\u6570\u5b57\u304c\u306a\u304b\u3063\u305f\u6642\n    else:\n        print(i)\n        break\n    i += 1", "passed": true, "time": 0.24, "memory": 14164.0, "status": "done"}, {"code": "i3=lambda : map(int,input().split())\n\nN,K=i3()\n*D,=i3()\n\nD=set(D)\n\nfor i in range(N,10**5):\n    ans=1\n    for s in str(i):\n        if int(s) in D:\n            ans=0\n            break\n    if ans : break\nprint(i)", "passed": true, "time": 0.14, "memory": 14332.0, "status": "done"}, {"code": "import sys\n\n\ndef check(pay, like):\n    str_pay = str(pay)\n    like = ''.join(like)\n    for p in str_pay:\n        for lk in like:\n            if p == lk:\n                return False\n\n    return True\n\nN, K = list(map(int, input().split()))\n\nD = []\nD = list(map(int, input().split()))\nstr_D = []\n\nfor s in D:\n    str_D.append(str(s))\n\npay = N\n\nwhile True:\n    if check(pay, str_D):\n        print(pay)\n        return\n    pay += 1\n", "passed": true, "time": 0.14, "memory": 14004.0, "status": "done"}, {"code": "def dfs(A: list):\n    if len(A) > nn:\n        return\n    if len(A) and (x := int(\"\".join(A))) >= n and ans[0] > x:\n        ans[0] = x\n        return\n\n    for v in d:\n        if v == \"0\" and len(A) == 0:\n            next\n        A.append(v)\n        dfs(A)\n        A.pop()\n\n\nn, k = list(map(int, input().split()))\nd = sorted(list(set([str(i) for i in range(10)]) - set(input().split())))\nnn = len(str(n))+1\nans = [10**7]\ndfs([])\nprint((ans[0]))\n", "passed": true, "time": 0.26, "memory": 14248.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nd = list(input().split())\n#n = 1000\nflag = True\nwhile flag:\n    flag2 = True\n    for si in str(n):\n        if si in d:\n            n += 1\n            flag2 = False\n            break\n    if flag2:\n        break\n    else:\n        flag = True\n            \nprint(n)\n", "passed": true, "time": 0.18, "memory": 14092.0, "status": "done"}, {"code": "def check(n, D):\n    N = []\n    while n != 0:\n        N.append(n % 10)\n        n //= 10\n    for d in D:\n        if d in N:\n            return False\n    return True\n\ndef __starting_point():\n    n, k = [int(x) for x in input().split(' ')]\n    D = [int(x) for x in input().split(' ')]\n    res = n\n    while True:\n        if check(res, D):\n            break\n        else:\n            res += 1\n    print(res)\n\n__starting_point()", "passed": true, "time": 0.23, "memory": 14216.0, "status": "done"}, {"code": "def is_dislike(N, ds):\n  num = N\n  while(True):\n    if (num % 10) in ds:\n      return True\n    else:\n      num = int(num / 10)\n      if num == 0:\n        break\n  return False\n\n\nnk = list(map(int,input().split()))\nN = nk[0]\nK = nk[1]\nds = list(map(int,input().split()))\nwhile(True):\n  if is_dislike(N, ds):\n    N = N+1\n  else:\n    print(N)\n    break", "passed": true, "time": 0.24, "memory": 14100.0, "status": "done"}, {"code": "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom math import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\nimport heapq\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\n#\n# \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7cfb\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nINF = float('inf')\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n  return list(map(int,readline().split()))\ndef readTuples():\n    return tuple(map(int,readline().split()))\ndef I():\n    return int(readline())\n\n#dic = defaultdict(int)\nn,k = readInts()\nD = Counter(readInts())\ndef ok(n):\n    while n:\n        v = n%10\n        if D[v]:\n            return False\n        n //= 10\n    return True\nans = n\nfor i in range(n, 100000):\n    if ok(i):\n        ans = i\n        break\nprint(ans)\n", "passed": true, "time": 0.17, "memory": 14224.0, "status": "done"}, {"code": "n, k = map(int, input().split())\narr = list(map(int, input().split()))\n\ninf = float('inf')\nmin_cost = inf\nfor amount in range(n, 100000):\n    for i, e in enumerate(arr):\n        if str(e) in str(amount):\n            break\n        if i == len(arr)-1:\n            min_cost = min(min_cost, amount)\n\nprint(min_cost)", "passed": true, "time": 0.29, "memory": 14168.0, "status": "done"}, {"code": "#\n# abc042 c\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"1000 8\n1 3 4 5 6 7 8 9\"\"\"\n        output = \"\"\"2000\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"9999 1\n0\"\"\"\n        output = \"\"\"9999\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N, K = list(map(int, input().split()))\n    D = list(input().split())\n\n    for i in range(100000):\n        if i < N:\n            continue\n        for d in D:\n            if str(i).count(d) != 0:\n                break\n        else:\n            print(i)\n            break\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14504.0, "status": "done"}, {"code": "n,k = input().split()\nhate = list(input().split())\nexi = True\nt = True\n\nwhile True:\n    for c in hate:\n        t = True\n        if c in list(n):\n            t = False\n            break\n    if t:\n        print(n)\n        break\n\n    intN = int(n) + 1\n    n = str(intN)", "passed": true, "time": 0.15, "memory": 14108.0, "status": "done"}, {"code": "import itertools\n\ndef main():\n\tN, K = [int(n) for n in input().split(\" \")]\n\tD = [1] * 10\n\tfor d in input().split(\" \"):\n\t\tD[int(d)] = 0\n\tL = [str(i) for i, v in enumerate(D) if v == 1]\n\n\tdigit = len(str(N))\n\tcand = []\n\tfor n in list(itertools.product(L, repeat=digit)):\n\t\tp = int(\"\".join(list(n)))\n\t\tif p >= N:\n\t\t\tcand.append(p)\n\tif len(cand):\n\t\tprint(min(cand))\n\telse:\n\t\tif L[0] == \"0\":\n\t\t\tprint(str(L[1]) + \"0\" * digit)\n\t\telse:\n\t\t\tprint(str(L[0]) * (digit + 1))\n\n\nmain()", "passed": true, "time": 0.15, "memory": 14140.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\ndef find_ok( x , Oks ):\n    for i in Oks:\n        if int(i) > int(x):\n            break\n    return i\n\ndef main():\n    n,k = map( int , input().split() )\n    Nos = set(map( int , input().split() ))\n    while(1):\n        x = str(n)\n        set_n= set()\n        for digit in x:\n            set_n.add( int(digit) )\n        if len(set_n & Nos) == 0:\n            break\n        n += 1\n    print(n)\n\n\n\nmain()", "passed": true, "time": 0.15, "memory": 14252.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\nd=set(input().split())\n\nwhile True:\n  if len(set(str(n))&d) != 0:\n    n+=1\n    \n  else:\n    print(n)\n    break\n", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[21]:\n\n\nimport itertools\n\ndef main():\n\tN, K = [int(n) for n in input().split(\" \")]\n\tD = [1] * 10\n\tfor d in input().split(\" \"):\n\t\tD[int(d)] = 0\n\tL = [str(i) for i, v in enumerate(D) if v == 1]\n\n\tdigit = len(str(N))\n\tcand = []\n\tfor n in list(itertools.product(L, repeat=digit)):\n\t\tp = int(\"\".join(list(n)))\n\t\tif p >= N:\n\t\t\tcand.append(p)\n\tif len(cand):\n\t\tprint((min(cand)))\n\telse:\n\t\tif L[0] == \"0\":\n\t\t\tprint((str(L[1]) + \"0\" * digit))\n\t\telse:\n\t\t\tprint((str(L[0]) * (digit + 1)))\n\n\nmain()\n\n\n# In[ ]:\n\n\n\n\n", "passed": true, "time": 0.15, "memory": 14284.0, "status": "done"}, {"code": "N,K = map(int,input().split())\nD = list(map(int,input().split()))\nE = []\nfor i in range(10):\n    if i not in D:\n        E.append(i)\nE = sorted(E)\nN = str(N)\nind = len(N)\nfor i in range(len(N)):\n    if int(N[i]) not in E:\n        ind = i\n        break\nif ind==len(N):\n    print(N)\nelse:\n    flag = 0\n    x = \"\"\n    for i in range(ind,-1,-1):\n        n = int(N[i])\n        for e in E:\n            if e>n:\n                x = N[:i]+str(e)+str(E[0])*(len(N)-i-1)\n                flag = 1\n                break\n        if flag==1:break\n    if flag==0:\n        if E[0]>0:\n            a = E[0]\n        else:\n            a = E[1]\n        x = str(a)+str(E[0])*len(N)\n    print(x)", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nds = [d for d in input().split()]\nwhile any(c in ds for c in str(n)): n += 1\nprint(n)", "passed": true, "time": 0.15, "memory": 14272.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nd = list(input().split())\nflg = True\nwhile flg:\n    flg = False\n    m = list(str(n))\n    for i in m:\n        if i in d:\n            flg = True\n            break\n    if flg:\n        n += 1\nprint(n)", "passed": true, "time": 0.14, "memory": 14280.0, "status": "done"}, {"code": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nb = set()\nfor i in range(10):\n  if i in a:\n    b.add(str(i))\nwhile n > 0:\n  c = set(list(str(n)))\n  if c.isdisjoint(b):\n    print(n)\n    return\n  n += 1", "passed": true, "time": 0.15, "memory": 14228.0, "status": "done"}, {"code": "# coding:UTF-8\nimport sys\n\n\ndef resultSur97(x):\n    return x % (10 ** 9 + 7)\n\ndef __starting_point():\n    # ------ \u5165\u529b ------#\n    nk = list(map(int, input().split()))     # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n\n    x = nk[1]\n    dList = list(map(int, input().split()))     # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n\n    # ------ \u51e6\u7406 ------#\n    f = 0\n    n = nk[0]\n    while f == 0:\n        nList = [int(c) for c in str(n)]  # \u6570\u5b57\u2192\u5358\u6570\u5b57\u30ea\u30b9\u30c8\u5909\u63db\n        b = 1\n        for i in nList:\n            for j in dList:\n                if i == j:\n                    b = 0\n                    break\n        if b == 1:\n            break\n        else:\n            n += 1\n\n    # ------ \u51fa\u529b ------#\n    print((\"{}\".format(n)))\n    # if flg == 0:\n    #     print(\"YES\")\n    # else:\n    #     print(\"NO\")\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14344.0, "status": "done"}, {"code": "import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return list(map(int,input().split()))\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float(\"inf\")\nal = \"abcdefghijklmnopqrstuvwxyz\"\nAL = al.upper()\n\nn,k = I()\nd = l()\nuse = [i for i in range(11) if i not in d ]\na = True\nprice = n\n\nwhile a:\n    cnt = 0\n    for i in str(price):\n        a = len(str(price))\n        if int(i) not in d:\n            cnt += 1\n        else:\n            cnt = inf\n        if a == cnt:\n            print(price)\n            return\n    price += 1\n    \n    \n    \n\n", "passed": true, "time": 0.16, "memory": 14232.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nd=list(map(str,input().split()))\ne=set(d)\nfor i in range(n,100001):\n  v = set(str(i))&e\n  if len(v)== 0:\n    print(i);return", "passed": true, "time": 0.14, "memory": 14064.0, "status": "done"}, {"code": "import itertools\nn,k = map(int, input().split())\nd = list(map(int, input().split()))\nsafe = [i for i in range(10) if i not in d]\n\nn_l = list(map(int, list(str(n))))\nif len(set(safe)&set(n_l)) == len(set(n_l)):\n    print(n)\n    return\n\nfor v in itertools.product(safe, repeat=len(str(n))):\n    if v[0] == 0: continue\n    x = int(\"\".join(list(map(str, v))))\n    if int(x) >= n:\n        print(x)\n        return\n\nfor v in itertools.product(safe, repeat=len(str(n))+1):\n    if v[0] == 0: continue\n    x = int(\"\".join(list(map(str, v))))\n    if int(x) >= n:\n        print(x)\n        return", "passed": true, "time": 0.16, "memory": 14396.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nd=set(input().split())\n \nwhile True:\n  if len(set(str(n))&d) != 0:\n    n+=1\n    \n  else:\n    print(n)\n    break", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nD = set(input().split())\n\nfor i in range(N, 100001):\n    for d in str(i):\n        if d in D:\n            break\n    else:\n        print(i)\n        break", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nd = list(map(int, input().split()))\n\nv = n\nwhile True:\n    f = True\n    for t in list(str(v)):\n        if int(t) in d:\n            f = False\n            continue\n    if f:\n        print(v)\n        return\n    v+=1\n", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "n,k = [int(x) for x in input().split()]\na = input().split()\n\ndef check(p):\n  p = list(str(p))\n  for i in range(len(p)):\n    if p[i] in a:\n      return False\n  return True\n\nfor i in range(n,n * 10000):\n  if check(i):\n    print(i)\n    break", "passed": true, "time": 0.2, "memory": 14160.0, "status": "done"}, {"code": "N,K=map(int,input().split())\n*D,=input().split()\nok=1\nwhile ok:\n    ans=list(str(N))\n    ok=0\n    for a in ans:\n        if a in D:\n            ok=1\n    N+=1\nprint(''.join(ans))", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nD = list(map(int, input().split()))\n\nfor i in range(n, 100000):\n  m = str(i)\n  count = 0\n  for j in range(len(m)):\n    if int(m[j]) in D:\n      break\n    else:\n      count += 1\n    if count == len(m):\n      print(i)\n      return\n      \nprint(0)", "passed": true, "time": 0.14, "memory": 14352.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\nl=list(map(int,input().split()))\nfor v in range(n,10**5):\n    for c in str(v):\n        if int(c) in l:\n            break\n    else:\n        print(v)\n        return\n", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "N, K = map(int,input().split())\nmat = input().split()\nwhile True:\n  FIN = 0\n  for i in range(len(str(N))):\n    for j in range(K):\n      if mat[j] == str(N)[i]:\n        FIN += 1\n        break\n  if FIN == 0:\n    break \n  else:\n    N += 1\nprint(N)", "passed": true, "time": 0.15, "memory": 14296.0, "status": "done"}, {"code": "n,k = [int(x) for x in input().split()]\nds = {int(x) for x in input().split()}\nns = {0,1,2,3,4,5,6,7,8,9} -ds\n#print(ds)\n#print(ns-ds)\ntemp=0\nd ={}\na=1\nb = {}\nm = len(str(n)) +1 \nover=False\nwhile(a<=m and not over ):\n  c = []\n  d = 10**(a-1) \n  for v in ns:\n    if a>1:\n      for bv in b[a-1]:\n        t = v*d + bv\n        c += [t]\n        if t >= n:\n          print(t)\n          over=True\n          break\n      if over:\n        break\n    else:\n      t = v*d\n      c += [t]\n      if t >= n:\n          print(t)\n          over=True\n          break\n      \n  b[a] = c\n  a+=1\n  \n#for j in b:    \n#    print(j,b[j])\n\n", "passed": true, "time": 0.14, "memory": 14152.0, "status": "done"}, {"code": "# N, K\u306e\u5165\u529b\u53d7\u4ed8\nN, K = map(int, input().split())\n# D\u306e\u5165\u529b\u53d7\u4ed8\nD = set(input().split())\n# 0-9\u3068D\u306e\u5dee\u96c6\u5408\u4f5c\u6210\u3001\u30ea\u30b9\u30c8\u5316\u3057\u3066E\u306b\u4ee3\u5165\nE = {\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"} - D\n# N\u306b1\u305a\u3064\u8db3\u3057\u3066\u6761\u4ef6\u306b\u5408\u3046\u6700\u521d\u306e\u6570\u5b57\u3092\u7279\u5b9a\u3059\u308b\nresult = False\nwhile result == False:\n    for i in str(N):\n        if not i in E:\n            N = N + 1\n            result = False\n            break\n        else:\n            result = True\nprint(N)", "passed": true, "time": 0.15, "memory": 14208.0, "status": "done"}, {"code": "n, k = map(int,input().split())\na = list(input().split())\n\nfor i in range(n, 100001):\n    flg = True\n    s = str(i)\n    for j in range(len(s)):\n        if s[j] in a:\n            flg = False\n            break\n    if flg:\n        break\nprint(i)", "passed": true, "time": 0.18, "memory": 14328.0, "status": "done"}, {"code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# import math\n# from itertools import *\n# import random\n# import calendar\nimport datetime\n# import webbrowser\n\n# f = open(\"input.txt\", 'r')\n# g = open(\"output.txt\", 'w')\n# n, m = map(int, f.readline().split())\n\nn, k = list(map(int, input().split()))\ndislike = list(map(int, input().split()))\nwhile True:\n    for i in str(n):\n        if int(i) not in dislike:\n            continue\n        else:\n            break\n    else:\n        break\n    n += 1\nprint(n)\n", "passed": true, "time": 0.16, "memory": 16376.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\nd = list(map(int,input().split()))\n#print(d)\nfor i in range(n,10**5):\n    count=0\n    for j in range(k):\n        u = str(d[j])\n        if(str(i).count(u)==0):\n            count+=1\n    #print(\"count:\"+str(count))\n    if(count==k):\n        print(i)\n        break\n", "passed": true, "time": 0.18, "memory": 14056.0, "status": "done"}, {"code": "def is_bad_nums(j: int, d: []) -> bool:\n    while j:\n        if j % 10 in d:\n            return True\n        j //= 10\n    return False\n\n\ndef answer(n: int, k: int, d: []) -> int:\n    for i in range(n, 100000):\n        if is_bad_nums(i, d):\n            continue\n        return i\n\n\ndef main():\n    n, k = map(int, input().split())\n    d = list(map(int, input().split()))\n    print(answer(n, k, d))\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.27, "memory": 14300.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nD = list(map(int, input().split()))\ns = set(D)\n\nfor i in range(N, 10**6+1):\n  l = [j for j in str(i)]\n  flag = True\n  for n in l:\n    if int(n) in s:\n      flag = False\n      break\n  if flag:\n    ans = i\n    break\nprint(ans)", "passed": true, "time": 0.15, "memory": 14364.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nd = list(input().split())\nwhile True:\n    flag2 = True\n    for si in str(n):\n        if si in d:\n            n += 1\n            flag2 = False\n            break\n    if flag2:\n        break            \nprint(n)", "passed": true, "time": 0.15, "memory": 14116.0, "status": "done"}, {"code": "def price(N,K):\n    Kn = input().split()\n    Flag = False\n\n    for i in range(N,10*N,1):\n        value = str(i)\n        for j in range(K):\n            if(Kn[j] not in value):\n                Flag = True\n            elif(Kn[j] in value):\n                Flag = False\n                break\n\n        if(Flag == True):\n            print(i)\n            break\n\nN,K = (int(x) for x in input().split())\nprice(N,K)", "passed": true, "time": 0.17, "memory": 14240.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\ndl = list(map(int, input().split()))\n\ni = n\nwhile True:\n    money = list(map(int, str(i)))\n    for m in money:\n        if dl.count(m) != 0:\n            break\n    else:\n        print(i)\n        break\n    i += 1\n    \n", "passed": true, "time": 0.27, "memory": 14312.0, "status": "done"}, {"code": "import sys\nsys.setrecursionlimit(10**7)\narr = [\"a\",\"b\",\"c\"]\nsavelis = [0]*10\ndef main():\n   N,K = list(map(int,input().split()))\n   Flis = list(map(int,input().split()))\n   Tlis = [i for i in range(10)]\n   Tlis = [i for i in Tlis if i not in Flis]\n   str_flis = [str(i) for i in Flis]\n   ANS = []\n   for i in range(N*10):\n      stri = str(i)\n      TF = True\n      for j in stri:\n         if j in str_flis:\n            TF = False\n            break\n      if(TF):ANS.append(i)\n   for item in ANS:\n      if(item>=N):\n         print(item)\n         break\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.34, "memory": 15872.0, "status": "done"}, {"code": "import itertools\n\nN, K = map(int, input().split()) # N\u5186\u306e\u54c1\u7269\u3001K\u500b\u306e\u5acc\u3044\u306a\u6570\u5b57\nD = set(list(map(int, input().split()))) # \u5acc\u3044\u306a\u6570\u5b57\u306e\u30ea\u30b9\u30c8\nbase = set(range(10))\n\ntarget_num = base - D\nketa = len(str(N))\n\nanswer = float('inf')\nfor p in itertools.product(target_num, repeat=keta):\n    temp = 0\n    for i, num in enumerate(p):\n        temp += num * 10**i\n        \n    if temp >= N:\n        answer = min(answer, temp)\n\nfor p in itertools.product(target_num, repeat=keta+1):\n    temp = 0\n    for i, num in enumerate(p):\n        temp += num * 10**i\n        \n    if temp >= N:\n        answer = min(answer, temp)\n\nprint(answer)", "passed": true, "time": 0.26, "memory": 14288.0, "status": "done"}, {"code": "n,k = list(map(int,input().split()))\n\na = list(input().split())\n\nwhile  not set(list(str(n)[0:k])).isdisjoint(a):\n\tn += 1\n\nprint(n)\n", "passed": true, "time": 0.17, "memory": 14112.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nD = list(input().split())\n\nans = str(n)\nwhile not all([c not in D for c in ans]) and int(ans) >= n:\n    ans = str(int(ans) + 1)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nd = list(map(int, input().split()))\nng = [False] * 10\nfor i in d:\n    ng[i] = True\ndef ok(n):\n    nonlocal ng\n    while n > 0:\n        if ng[n%10]:\n            return False\n        n //= 10\n    return True\nwhile not ok(n):\n    n += 1\nprint(n)", "passed": true, "time": 0.15, "memory": 14132.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nd = set(map(int, input().split()))\n\nwhile True:\n    tmp_str = set(str(n))\n    for i in tmp_str:\n        if int(i) in d:\n            n += 1\n            break\n    else:\n        print(n)\n        break\n", "passed": true, "time": 0.15, "memory": 14348.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nd=list(map(int,input().split()))\nx=list(range(1,100001))\ny=[0]*100000\nfor i in range(100000):\n    s=str(i)\n    S=len(s)\n    for j in range(S):\n        if int(s[j]) in d:\n            y[i-1]=1\n            break\nfor i in range(100000):\n    if i>=n-1:\n        if y[i]==0:\n            print(i+1)\n            break", "passed": true, "time": 0.33, "memory": 17972.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nD = set(map(int, input().split()))\nfrom itertools import count\nfor ans in count(n,1):\n    for c in str(ans):\n        if int(c) in D:\n            break\n    else:\n        print(ans)\n        break", "passed": true, "time": 0.15, "memory": 14200.0, "status": "done"}, {"code": "def iparse():\n    return list(map(int, input().split()))\n\nn, k = iparse()\nd = iparse()\n\nfor i in range(n, 5000000):\n    tmp = i\n    f = True\n    while tmp > 0:\n        x = tmp % 10\n        if x in d:\n            f = False\n            break\n        tmp //= 10\n    if f:\n        print(i)\n        return\n\n", "passed": true, "time": 0.2, "memory": 14128.0, "status": "done"}, {"code": "from sys import stdin\ninput = stdin.readline\n\nN, K = map(int, input().split())\nD = set(map(int, input().split()))\n\nwhile True:\n    tmp = set(str(N))\n    b = True\n    for x in tmp:\n        if int(x) in D:\n            b = False\n            break \n    if b == True:\n        break\n    else:\n        N += 1\n\nprint(N)", "passed": true, "time": 0.15, "memory": 14120.0, "status": "done"}, {"code": "N,K = input().split()\nD =list(map(int,input().split()))\nans = []\na = int(N[0])\nx = 0\nb = 0\nwhile b in D:\n    b += 1\nc = 2\nwhile c in D:\n    c += 1\ny = 0\nwhile a == int(N[x]) and x <= len(N)-1:\n    while a in D and a <= 9:\n        a += 1\n    if  a == 10:\n        y = x\n        if 0 in D:\n            a += b\n        if 1 in D:\n            if b != 0:\n                a += (b-1)*10\n            else:\n                a += (c-1)*10\n    ans.append(str(a))\n    if a != int(N[x]):\n        for i in range(len(N)-1-x):\n            ans.append(str(b))\n    elif x <= len(N)-2:\n        x += 1\n        a = int(N[x])\n    else:\n        a = int(N[x])-1\nwhile y > 0:\n    s = ans[y][0]\n    t = ans[y][1]\n    r = ans[y]\n    ans[y] = t\n    ans[y-1] = str(int(ans[y-1]) + 1)\n    if int(ans[y-1]) in D:\n        u = int(ans[y-1])\n        while u in D:\n            u += 1\n            ans[y-1] = str(u)\n    if ans[y-1] != \"10\":\n        y = 0\n    else:\n        y -= 1\n        ans[y] = r\nprint(\"\".join(ans))", "passed": true, "time": 0.14, "memory": 14396.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nd = list(input().split())\nnum = [str(i) for i in range(10)]\nfor i in range(k):\n    num.remove(d[i])\n    \nimport itertools, heapq\nans = []\nheapq.heapify(ans)\nfor i in itertools.product(num, repeat=len(str(n))):\n    s = int(''.join(i))\n    if s >= n:\n        heapq.heappush(ans, s)\n        \nif len(ans) == 0:\n    for i in itertools.product(num, repeat=len(str(n)) + 1):\n        s = int(''.join(i))\n        if s >= n:\n            heapq.heappush(ans, s)\n    print(heapq.heappop(ans))\n    \nelse:\n    print(heapq.heappop(ans))", "passed": true, "time": 0.14, "memory": 14148.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nd = list(map(int, input().split()))\ns = {'0','1','2','3','4','5','6','7','8','9'} - set(str(d))\nans = n\n\nwhile (s >= set(str(n))) == False:\n  n += 1\n  if (s >= set(str(n))) == True:\n    ans = n\n    break\n    \nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14232.0, "status": "done"}, {"code": "def main():\n    N, K = map(int, input().split())\n    A_list = list(map(str, input().split()))\n    use_list = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]\n    list_A = list(set(use_list) - set(A_list))\n    #print(\"list_A\", list_A)\n    for i in range(100000) :\n        ans = N + i\n        #print(\"ans\", ans)\n        ans_str = str(ans)\n        frag = 0\n        for val in ans_str :\n            #print(\"val\", val)\n            if str(val) in list_A :\n                pass\n                #print(\"frag\", frag)\n            else :\n                frag = 1\n                break\n\n        if frag == 0 :\n            break\n    print(ans)\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "def main():\n    N, K = list(map(int, input().split()))\n    D = set(map(int, input().split()))\n    numset = set(range(0,10))\n    d = numset.difference(D)\n\n    for n in range(N, pow(10, 6) + 10):\n        check = set(list(str(n)))\n        ngflag = False\n        for i in check:\n            if int(i) in D:\n                ngflag = True\n                break\n        if not ngflag:\n            break\n    print(n)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.22, "memory": 14212.0, "status": "done"}, {"code": "N, K = [int(x) for x in input().split()]\nD = input().split()\n\nfor payment in range(N, 10*N+1):\n    if all(char not in D for char in str(payment)):\n        print(payment)\n        break", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nd = list(input().split())\nnum = [str(i) for i in range(10)]\nfor i in range(k):\n    num.remove(d[i])\n    \nimport itertools\nans = []\nfor i in itertools.product(num, repeat=len(str(n))):\n    s = int(''.join(i))\n    if s >= n:\n        ans.append(s)\n        \nif len(ans) == 0:\n    for i in itertools.product(num, repeat=len(str(n)) + 1):\n        s = int(''.join(i))\n        if s >= n:\n            ans.append(s)\n    print(min(ans))\n    \nelse:\n  print(min(ans))", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nS = set(input().split())\nwhile True:\n    L = list(str(N))\n    for i in L:\n        if i in S:\n            break\n    else:\n        break\n    N += 1\nprint(N)", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nd = list(map(int, input().split()))\n\nwhile True:\n    for i in str(n):\n        if int(i) in d:\n            n += 1\n            break\n    \n    else:\n        print(n)\n        break", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "n,t = [int(x) for x in input().split()]\nd = [int(x) for x in input().split()]\n\ndef check(x) -> bool:\n    while x>0:\n        a = x%10\n        if a in d:\n            return False\n        x//=10\n    return True\n\nwhile check(n)==False:\n    n+=1\nprint(n)", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nd=set(input().split())\nwhile True:\n    if len(set(str(n))&d)!=0:\n        n+=1\n    else:\n        break\nprint(n)", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "def minN(N:int, usable:list, restrict=True):\n    usable.sort()\n    keta = False\n    if restrict:\n        for i in usable:\n            if i >= N:\n                return str(i)\n        # \u6841\u304c\u5897\u3048\u308b\n        return '1'+str(usable[0])\n    else:\n        return str(usable[0])\n\ndef rote(N:list, D:set, d:set):\n    ans = []\n    flag = True\n    lenNstr = len(N)\n    for i, n in enumerate(N):\n        n = int(n)\n        keta = 10**(len(N) - i - 1)\n        if flag:\n            if n in D:\n                ans.append(int(minN(n, d)) * keta)\n                flag = False\n            else:\n                ans.append(keta * n)\n        else:\n            ans.append(keta * min(d))\n    return sum(ans)\n\ndef main():\n    N, K = list(map(int, input().split()))\n    D = set(map(int, input().split()))\n    numset = set(range(0,10))\n    d = list(numset.difference(D))\n    d.sort()\n    for _ in range(10):\n        Nstr = list(str(N))\n        ans = rote(Nstr, D, d)\n        N = ans    \n    print(ans)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "N,K = list(map(int,input().split()))\n\nD = list(map(int,input().split()))\n\ndef ok(x):\n    while x:\n        if x % 10 in D:\n            return False\n        x //= 10\n    return True\n\nfor i in range(N,100000):\n    if ok(i):\n        print(i)\n        return\n", "passed": true, "time": 0.14, "memory": 14164.0, "status": "done"}, {"code": "N,K=map(int,input().split())\nD=list(map(int,input().split()))\n\nwhile True:\n  S=str(N)\n  flag=True\n  for x in S:\n    if int(x) in D:\n      flag=False\n  if flag==True:\n    break;\n  N+=1\nprint(N)", "passed": true, "time": 0.14, "memory": 14228.0, "status": "done"}, {"code": "n,k=map(int,input().split());a=set(input().split())\nwhile True:\n  if not set(str(n))&a: print(n);break\n  n+=1", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "N, K = list(map(int, input().split()))\nkirai = list(map(int, input().split()))\nwhile True:\n  bara = [int(x) for x in list(str(N))]\n  diff = set(kirai) & set(bara)\n  if diff == set():\n    print(N)\n    break\n  else:\n    N = N + 1\n", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}]