N,K=map(int,input().split()) P=list(map(int,input().split())) X=0 for B in range(401): A=0 for p in P: if p>=B: A+=1 if A<=K: X=max(A,X) print(X)