n, k = map(int, input().split()) P = list(map(int, input().split())) P.sort() import bisect ans = 0 for b in range(0, 402): i = bisect.bisect_left(P, b) if n-i > k: continue else: ans = max(ans, n-i) print(ans)