n,k = map(int,input().split()) P = list(map(int,input().split())) ans = 0 for i in range(401): cnt = 0 for j in range(n): if P[j] >= i: cnt += 1 if cnt <= k: ans = max(ans,cnt) print(ans)