n,k=map(int,input().split()) P=list(map(int,input().split())) l=[i for i in range(0,402)] anss=[] for x in l: ans=0 for i in range(n): if l[i]>=x: ans+=1 anss.append(ans) ans=0 anss.sort() for x in anss: if k>=x: ans=x print(ans)