# 完全全探索でO(N x max(pi)) # あえてcnt部をbisect from bisect import * N, K = map(int, input().split()) P = list(map(int, input().split())) P.sort() ans = 0 for B in range(401): cnt = N - bisect_left(P,B) if cnt <= K: ans = max(ans,cnt) print(ans)