n,k=map(int,input().split()) P=list(map(int,input().split())) P.sort() for i in range(401): ans=0 for x in P: if x>=i: ans+=1 if ans<=k: print(ans) exit()