import sys
input = sys.stdin.readline

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

LIST=[0]*(N+3)

for a in A:
    if a<N+3:
        LIST[a]+=1

for j in range(N+3):
    if LIST[j]==0:
        now=j
        break

for i in range(5*N):
    A.append(now)
    LIST[now]+=1
    if A[i]<N+3:
        LIST[A[i]]-=1

        if LIST[A[i]]==0 and now>A[i]:
            now=A[i]

    while LIST[now]!=0:
        now+=1

if X-1<len(A):
    print(A[X-1])
else:
    k=X%(N+1)
    print(A[k+N])