import bisect n, k = map(int, input().split()) p = list(map(int, input().split())) s = sorted(p) candidates = set() # Add boundary conditions candidates.add(0.0) # All students pass if B is 0 for i in range(n): candidates.add(s[i]) if i < n - 1 and s[i] < s[i+1]: mid = (s[i] + s[i+1]) / 2 candidates.add(mid) # Add a value larger than the maximum score if n > 0: candidates.add(s[-1] + 1) else: candidates.add(0.0) max_count = 0 for b in candidates: j = bisect.bisect_left(s, b) count = n - j if count <= k and count > max_count: max_count = count print(max_count)