Harryxun/stf_run huggingface dataset:
def main():
    a = input()
    #if int(a) > 100000:
    #    exit
    l = list(map(int,input().split()))
    #if len(l) > int(a):
    #    exit
    ans = check(int(a),l)
    print(ans)

def check(a,l):
    num = 0
    for i in range(a):
        for j in range(i):
            if l[i] > l[j]:
                break
        else:
            num = num + 1
    return num

main()

### FIXED CODE ###

def main():
  a,b = map(int,input().split())
  ans = check(a,b)
  print(ans)
  
def check(n,m):
  if n == m:
    return "Yes"
  else:
    return "No"
main()
H,N = map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if N>=2:
  if lists[N-1]+lists[N-2]>=H:
    print('Yes')
  else:
    print('No')
else:
  if lists[0]>=H:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)
n = int(input())
s_n = 0
for i in str(n):
    s_n += i
if n%s_n == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
s_n = 0
for i in str(n):
    s_n += int(i)
if n%s_n == 0:
    print("Yes")
else:
    print("No")
n = int(input())
a = input()
b = input()

ans = 3
i = 0
if a[0] != b[0]:
    i += 1
    ans += 3

while i < n-1:
    if a[i]==b[i]:
        if a[i+1]==b[i+1]:
            ans *= 2
        else:
            ans *= 2
            i += 1
    else:
        if a[i+1]==b[i+1]:
            ans *= 1
        else:
            ans *= 3
            i += 1
    i += 1
    ans %= 1000000007
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
f,s,i = 0,0,0
while i+1<n:
    if a[i]==a[i+1]:
        s = f
        f = a[i]
        i += 1
    i += 1
print(f*s)
s = input()
print(s.replace(a[0:4], '2018'))


### FIXED CODE ###

s = input()
print(s.replace(s[0:4], '2018'))
s = input()
k = int(input())
for i in range(k):
  if s[i] != '1':
    print(c)
    break
else:
  print(s[k - 1])


### FIXED CODE ###

s = input()
k = int(input())
for i in range(min(len(s), k)):
  if s[i] != '1':
    print(s[i])
    break
else:
  print(s[k - 1])
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Mmax = max(Mlis)
Midx = [i+1 for i, v in enumerate(Mlis) if v == Mmax]

if [Hidx, Midx] in lis:
    print(Hmax + Mmax -1)
else:
    print(Hmax+Mmax)
          

### FIXED CODE ###

import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)
import sys
s = list(input())
if s[0] == "A" and s[2:-1].count("C") == 1:
  cnt = 0
  for i in s:
    if s.isupper():
      cnt += 1
  if cnt == 2:
    print("AC")
    sys.exit()
print("WA")

### FIXED CODE ###

S = input()
Flag = False
if (S[0]=='A') and S[2:len(S)-1].count('C')==1:
    ReS = S.replace('C','')[1:]
    if ReS.islower():
        Flag = True
if Flag:
    print('AC')
else:
    print('WA')
n=int(input())
a=list(map(int,input().split()))

sm=a[0]
ans=[0, 0]
for i in range(n-1):
    sm1=sm+a[i+1]
    if sm*sm1>=0:
        ans[0]+=abs(sm1)+1
        sm//=abs(sm)*(-1)
    else:
        sm=sm1


sm=-1
ans[1]+=abs(a[0])+1
for i in range(n-1):
    sm1=sm+a[i+1]
    if sm*sm1>=0:
        ans[1]+=abs(sm1)+1
        sm//=abs(sm)*(-1)
    else:
        sm=sm1
print(min(ans))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))

ans=[0, 0]
if a[0]!=0:
    sm=a[0]
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[0]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1

    if a[0]>0:
        sm=-1
    else:
        sm=1
    ans[1]+=abs(a[0])+1
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[1]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1
if a[0]==0:
    sm=1
    ans[0]+=1
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[0]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1

    sm=-1
    ans[1]+=1
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[1]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1
print(min(ans))
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if N % di == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if int(N) % di == 0:
    print("Yes")
else:
    print("No")
import sys
a,b=map(int,input().split())

if a%2==0:
  lower1=int(a*100/8)
  upper1=(a+1)*100/8
  upper1=max(lower,int(upper1)-1)  
else:
  lower1=a*(100/8)
  upper1=int((a+1)*100/8)
  if (upper1)-int(lower1)<=1:
    print(-1)
    sys.exit()
  else:
    lower1=int(lower1)+1
    if lower1==upper1:
      print(-1)
      sys.exit()
    else:
      pass
  
lower2=(b)*10
upper2=(b+1)*10

lower=max(lower1,lower2)
upper=min(upper1,upper2)
if upper-lower<0:
  print(-1)
else:
  print(lower)



### FIXED CODE ###

import sys
a,b=map(int,input().split())

if a%2==0:
  lower1=int(a*100/8)
  upper1=(a+1)*100/8
  upper1=max(lower1,int(upper1)-1)  
else:
  lower1=a*(100/8)
  upper1=int((a+1)*100/8)
  if (upper1)-int(lower1)<=1:
    print(-1)
    sys.exit()
  else:
    lower1=int(lower1)+1
    if lower1==upper1:
      print(-1)
      sys.exit()
    else:
      pass
  
lower2=(b)*10
upper2=(b+1)*10

lower=max(lower1,lower2)
upper=min(upper1,upper2)
if upper-lower<1:
  print(-1)
else:
  print(lower)
from random import shuffle
from collections import Counter
def inpl(): return list(map(int, input().split()))

#N = 20000
#P = list(range(1, N+1))
#shuffle(P)

N = int(input())
P = inpl()

A = [0]*N
B = [0]*N
S = [10**9 - N] * (N)
for i, p in enumerate(P):
    S[p-1] += i

A[0] = 1
B[0] = S[0] - 1

for i in range(1, N):
    A[i] = max(A[i-1] + 1, S[i] - B[i-1] + 1)
    B[i] = S[i] - A[i]

for i in range(N-1):
    assert A[i] < A[i+1]
    assert B[i] > B[i+1]

assert B[-1] > 0
print(*A)
print(*B)


### FIXED CODE ###

def inpl(): return list(map(int, input().split()))

H, W = inpl()
A = []
for _ in range(H):
    A.append([x=="#" for x in input()] + [False])

A.append([False] * (W+1))

Q = [[0, 0]]
visited = [[False]*(W+1) for _ in range(H+1)]
visited[0][0] = True

while Q:
    h, w = Q.pop()
    for dh, dw in [[0, 1], [1, 0]]:
        nh, nw = h+dh, w+dw
        if A[nh][nw] and not visited[nh][nw]:
            visited[nh][nw] = True
            Q.append([nh, nw])

plength = sum([sum(a) for a in A])

if plength == (H+W-1) and visited[H-1][W-1]:
    print("Possible")
else:
    print("Impossible")
abc=list(map(int,input().split()))
a,b,c=abc[0],abc[1],abc[2]
k=int(input())
for i in range(k):
    if a < b < c:
        print("Yes")
        break
    elif b < a < c:
        b *= 2
    else:
        c *= 2:
else:
    print("No")

### FIXED CODE ###

abc=list(map(int,input().split()))
a,b,c=abc[0],abc[1],abc[2]
k=int(input())
for i in range(k+1):
    if a < b < c:
        print("Yes")
        break
    elif b <= a < c:
        b *= 2
    else:
        c *= 2
else:
    print("No")
N, K = map(int, input().split())

if(K==1 or N==K):
  return 0
return N-K

### FIXED CODE ###

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

if(K==1):
  print(0)
else:
  print(N-K)
n = int(input())
d = list(map(int,input().split())) 
D = sorted(d)
if D[n//2-1]==D[n//2]:
    print(0)
else:
    print(D[n//2+1]-D[n//2]+1)

### FIXED CODE ###

n = int(input())
d = list(map(int,input().split())) 
D = sorted(d)
if D[n//2-1]==D[n//2]:
    print(0)
else:
    print(D[n//2]-D[n//2-1])
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,p = readInts()
    A = readInts()
    cnt = 0
    for bit in range(1 << n):
        now = 0
        for i in range(n):
            if bit & (1 << i):
                now += A[i]
        if now % 2 == p:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()


### FIXED CODE ###

from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,p = readInts()
    m = 0
    A = readInts()
    for i in range(n):
        a = A[i]
        if a % 2 == 1:
            m += 1
    if m == 0:
        print(2**n if p == 0 else 0)
    else:
        print(2**(n-1))
if __name__ == '__main__':
  main()
s = input()

n = []*26

for e in s:
  n[e-'a']+=1
  
for i in n:
  if i>1:
    print("no")
    return
print("yes)

### FIXED CODE ###

s = input()
n = [0]*26
for e in s:
  n[ord(e)-ord('a')]+=1
for i in n:
  if i>1:
    print("no")
    exit()
print("yes")
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))




n = int(input())
minsum = [None] * n # (min, sum)
for i in range(n):
    tmp = list(map(int, " ".join(input()).replace("(", "1").replace(")", "-1").split()))
    c = 0
    m = 0
    for item in tmp:
        c += item
        m = min(c, m)
    minsum[i] = (m, sum(tmp))
minsum.sort()

if sum(item[1] for item in minsum)!=0:
    print("No")
else:
    c = 0
    i = n-1
    while True:
        m, s = minsum[i]
        if m<0:
            break
        c += s
        i -= 1
        minsum.pop()
    minsum.sort(key=lambda x: x[1])
#     print(minsum, c)
    i = len(minsum)-1
    while minsum:
        m, s = minsum[i]
        if c+m>=0:
            minsum.pop(i)
            c += s
            i = len(minsum) - 1
        else:
            i -= 1
            if i<0:
                print("No")
                break
    else:
        print("Yes")

### FIXED CODE ###

def main():
    import queue
    import sys
    input = lambda : sys.stdin.readline().rstrip()
    sys.setrecursionlimit(max(1000, 10**9))



    n = int(input())
    minsum = [None] * n # (min, sum)
    for i in range(n):
        tmp = list(map(int, " ".join(input()).replace("(", "1").replace(")", "-1").split()))
        c = 0
        m = 0
        for item in tmp:
            c += item
            m = min(c, m)
        minsum[i] = (m, sum(tmp))
    minsum.sort()

    if sum(item[1] for item in minsum)!=0:
        print("No")
    else:
        minsum1 = [item for item in minsum if item[1]>=0]
        minsum2 = [(item[0]-item[1], -item[1]) for item in minsum if item[1]<0]
        minsum2.sort()
        c = 0
        for m,s in minsum1[::-1]:
            if c+m>=0:
                c += s
            else:
                print("No")
                return
        c = 0
        for m,s in minsum2[::-1]:
            if c+m>=0:
                c+=s
            else:
                print("No")
                return
        print("Yes")
main()
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(float, input().split()))

low=-1
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)

### FIXED CODE ###

# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(float, input().split()))

low=0
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)
N = int(input())
total = 0
for i in range(1,N+1):
	if i%3!=0 and i%5!=0:
    	total += i
print(total)    

### FIXED CODE ###

N = int(input())
total = 0
for i in range(1, N+1):
    if (i % 3) != 0 and (i % 5) != 0:
        total = total+i
print(total)
a,b=map(int,input().split())
grid=[['#' for i in range(60)] for i in range(20)]
grid=grid+[['.' for i in range(60)] for i in range(20)]

for i in range(1200):
  amari=i%60
  shou=int(i/60)
  if (amari + shou)%2==0:
    grid[shou][amari]='.'
    a-=1
  if a==1:
    break

for i in range(1200):
  if (amari + shou)%2==0:
    grid[shou+22][amari]='#'
    b-=1
  if b==1:
    break

for i in range(40):
  print(''.join(grid[i]))

### FIXED CODE ###

a,b=map(int,input().split())
k=32
m=2*k
grid=[['#' for i in range(m)] for i in range(k)]
grid=grid+[['.' for i in range(m)] for i in range(k)]

for i in range(m*k):
  if a==1:
    break
  grid[2*int(i*2/m)][(i*2)%m]='.'
  a-=1

for i in range(m*k):
  if b==1:
    break
  grid[k+1+2*int(i*2/m)][(i*2)%m]='#'
  b-=1

print(str(2*k)+' '+str(2*k))
for i in range(k*2):
  print(''.join(grid[i]))
a,b,c,d = map(int,input().split())

if b <= c:
  print(0)
  exit()
  
if b <= d:
  print(b-c)
else:
  print(d-c)


### FIXED CODE ###

N = input()

print("Yes" if N[0] == N[2] else "No")
import re
try:
    ls = num = []
    result = 0
    while True:
        ls.append(input())
except:
    for i in ls:
        for s in range(re.findall(r'\d+', i)):
            result += int(s)
    print(result)

### FIXED CODE ###

import re
try:
    result = 0
    while True:
        for s in re.findall(r'\d+', input()):
            result += int(s)
except:
    print(result)
from collections import deque

def getInts():
    return [ int(x) for x in input().split() ]

def complement(c):
    if c=='1':
        return '0'
    else:
        return '1'

H = {}

def pop(n):
    return "{0:b}".format(n).count('1')
def toZero(n):
    if n==0:
        return 0
    if n==1:
        return 1
    if n in H:
        return H[n]
    r = 1 + toZero(n%pop(n))
    H[n] = r
    return r

[N] = getInts()
X = input()
Xi = int(X, 2)
X = list(X)

i=0
p = pop(Xi)
while 2**i < Xi:
    toZero(2**i%(p+1))
    toZero(2**i%(p-1))
    i+=1
for i in range(N):
    X[i] = complement(X[i])
    n = int("".join(X),2)
    print(toZero(n))
    X[i] = complement(X[i])

### FIXED CODE ###

def getInts():
    return [ int(x) for x in input().split() ]

[L,R,d] = getInts()

c = 0
for i in range(L, R+1):
    if i%d==0:
        c+=1
print(c)
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    A = [int(x) - 1 for x in input().split()]

    way = []
    now = 0
    for _ in range(K):
        if now in way:
            loop_start = way.index(now)
            loop = way[loop_start:]
            K -= len(way[:loop_start])
            now = loop[K - len(way[:loop_start]) % len(loop)]
            break
        way.append(now)
        now = A[now]
    print(now + 1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    A = [int(x) - 1 for x in input().split()]

    way = []
    seen = [False for _ in [0] * (2 * 10 ** 5 + 1)]
    now = 0
    for _ in range(K):
        if seen[now]:
            loop_start = way.index(now)
            loop = way[loop_start:]
            K -= len(way[:loop_start])
            now = loop[K % len(loop)]
            break
        way.append(now)
        seen[now] = True
        now = A[now]
    print(now + 1)


if __name__ == '__main__':
    main()
def binary_search(A,n,l):
    # sequence A, item n, l len(A)
    if l==0:
        return False
    elif A[l/2] > n:
        return binary_search(A[:l/2],n)
    elif A[l/2] == n:
        return True
    elif A[l/2]<n:
        return binary_search(A[(l/2)+1:],n)

n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())

l = len(S)
C = 0
for k in T:
    if binary_search(S,k,l):
        C += 1
print C

### FIXED CODE ###

# coding: utf-8
# Here your code !
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
C = 0

def binary_search(A,n):
    """no recursion version"""
    l = len(A)
    left = l/2
    right = l-1
    while A[left] != n:
        if left == right and A[left] != n:
            #print left,right,"if"
            return False
        elif A[left] > n: # n????????????????????´???
            right = left
            left = left/2
            #print left,right,"elif1"
        elif A[left] < n: # n????????????????????´???
            right = right
            left = (left + right-1)/2 + 1
            #print left,right,"elif2"
    else:
        return True

for item in T:
    if binary_search(S,item):
        C += 1
print C
n, d = map(int, input().split())
print(math.ceil(n / (2*d +1)))

### FIXED CODE ###

import math
n, d = map(int, input().split())
print(math.ceil(n / (2*d +1)))
s=input()
con=[0]*2
for i in range(4):
    if s[i]=='+':
        c[0]+=1
    else:
        c[1]+=1
print(c[0]-c[1])           

### FIXED CODE ###

s=input()
con=[0]*2
for i in range(4):
    if s[i]=='+':
        con[0]+=1
    else:
        con[1]+=1
print(con[0]-con[1])
import math

def gcd_list(arr):

    ans = arr[0]
    for c in arr[1::]:
        ans = math.gcd(ans , c)
    return ans

N = int(input())

A = list(map(int, input().split()))

g = gcd_list(A)

for i in range(N):
    tmp = A.pop(0)
    if g < gcd_list(A):
        g = gcd_list(A)
    A.append(tmp)

print(g)


### FIXED CODE ###

'''
import math

def gcd (a,b):
    if (b == 0):
        return a
    else:
        return gcd(b, a % b)

def gcd_list(arr):

    ans = arr[0]
    for c in arr[1::]:
        ans = gcd(ans , c)
    return ans
'''
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())

A = list(map(int, input().split()))
A.sort()

af = A[0]
ag = A[1]

F = make_divisors(af)
G = make_divisors(ag)
F.sort(reverse=True)
G.sort(reverse=True)
del F[-1]
del G[-1]

'''
print(F)
print(G)
'''

ansf = 1
ansg = 1

for i in F:
    count = 0
    for j in A:
        if j % i != 0:
            count += 1
            if count == 2:
                break

    if count == 1:
        ansf = i
        break
    if count == 0:
        ansf = i
        break

for i in G:
    count = 0
    for j in A:
        if j % i != 0:
            count += 1
            if count == 2:
                break

    if count == 1:
        ansg = i
        break

print(max(ansf,ansg))
'''
g = gcd_list(A)
print(g)

for i in range(N):
    tmp = A.pop(0)
    if g < gcd_list(A):
        g = gcd_list(A)
    A.append(tmp)

print(g)
'''
n = input()
s = input()
if s == n[0] == 1:
  print(1)
else:
  print(n[1])

### FIXED CODE ###

s = input()
k = int(input())
lens = len(s)
ans = 1
for i in range(k):
    if i == lens:
        break
    if s[i] != "1":
        ans= s[i]
        break
print(ans)
X, Y, A, B, C = map(int, input().split())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))
r_list = list(map(int, input().split()))

eat = []
for i in range(X):
  p_max = max(p_list)
  r_max = max(r_list)
  if p_max >= r_max or len(r_list) == 0:
    eat.append(p_max)
    p_list.remove(p_max)
  else:
    eat.append(r_max)
    r_list.remove(r_max)
for i in range(Y):
  q_max = max(q_list)
  r_max = max(r_list)
  if q_max >= r_max or len(r_list) == 0:
    eat.append(q_max)
    q_list.remove(q_max)
  else:
    eat.append(r_max)
    r_list.remove(r_max)
print(sum(eat))

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse = True)[: X]
q = sorted(list(map(int, input().split())), reverse = True)[: Y]
r = list(map(int, input().split()))

all_apple = sorted(p + q + r, reverse = True)
print(sum(all_apple[: X + Y]))
N, K = list(map(int, input().split()))
D = list(map(int, input().split()))

number = [i for i in range(10)]
num_lis = list(set(number) - set(D))
ans=[]
for i in num_lis:
    for j in num_lis:
        for k in num_lis:
            for l in num_lis:
                a = 1000*i + 100 *j + 10*k + l
                if a>=N:
                    ans.append(a)
print(ans[0])

### FIXED CODE ###

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

number = [i for i in range(10)]
num_lis = list(set(number) - set(D))
ans=[]
for i in range(N, 100000):
    a=i//10000
    if bool((a not in D) or i <10000):
        b=i//1000 - 10*a
        if bool((b not in D) or i <1000):
            c=i//100 - 100 * a - 10 * b
            if bool((c not in D) or i < 100):
                d= i//10 - 1000 * a - 100*b - 10*c
                if bool((d not in D) or i <10):
                    e=i%10
                    if e not in D:
                        ans.append(i)
print(ans[0])
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
b_list = [0] * N
b_list[-1] = a_list[-1]

for i in range(N):
    # 大きい方から決めていく
    idx = N - (i + 1)
    total = 0
    for j in b_list[:: idx + 1]:
        # idx + 1の倍数のボールの個数を数える
        total += b_list[j]

    if total % (idx + 1) != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i + 1) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list)
print(ans)
print(" ".join(idx_list))


### FIXED CODE ###

#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = sum(b_list[idx : N + 1 : idx])

    if total % 2 != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))
while True:
 
 sum=0
 n=input()
 i=1
 j=2
 if n==3:sum=2
 else :
  while i<=n:
   while j<i:
    if i%j==0:break
    j+=1
   if i==j:sum+=1
  
   if n%2==0:i+=2
   elif n%2!=0 and i==n-2:i+=1
   else :i+=2
 print sum

### FIXED CODE ###

num=1000000
prime=[1]*1000000
prime[0]=0
prime[1]=0
i=2
ans=0
while i<1000000:
 if prime[i]==1:
  ans+=1
 if i<1000:
  j=i*i
  while j<1000000:
   prime[j]=0
   j+=i
 prime[i]=ans
 i+=1
while True:
 try:
  n=input()
  print prime[n]
 except:
  break
a,b=map(int,input().split())

print(a*b//2)


### FIXED CODE ###

a,b,c=map(int,input().split())

print(a*b//2)
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

sin=p[:-x]+q[:-y]
sin.sort(reverse=True)

r.sort(reverse=True)

ans=sum(sin)

for i in sin:
  if r[0]>i:
    ans+=r[0]-i
    r.pop(0)
    

print(ans)


### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort()
q.sort()


sin=p[a-x:]+q[b-y:]+r

sin.sort()

print(sum(sin[len(sin)-x-y:]))
print((lambda n,a,b:max(n*a, b))(*[int(x) for x in input().split()])

### FIXED CODE ###

print((lambda n,a,b:min(n*a, b))(*[int(x) for x in input().split()]))