# 完全全探索でO(N x max(pi)) N, K = map(int, input().split()) P = list(map(int, input().split())) ans = 0 for B in range(401): cnt = 0 for p in P: if p >= B: cnt += 1 if cnt <= K: ans = max(ans,cnt) print(ans)