N, K = map(int, input().split()) P = list(map(int, input().split())) from bisect import bisect_left P.sort() ans = 0 for B in range(401): if N - bisect_left(P, B) <= K: ans = max(ans, N - bisect_left(P, B)) print(ans)