import sys from collections import Counter from itertools import accumulate def main(): n, k = map(int, sys.stdin.readline().split()) a = list(map(int, sys.stdin.readline().split())) freq = Counter(a) freqs = sorted(freq.values(), reverse=True) prefix = list(accumulate(freqs, initial=0)) # prefix[0]=0, prefix[1] = freqs[0], etc. low = 1 high = len(freqs) ans = high # Initialize with the maximum possible value while low <= high: mid = (low + high) // 2 if mid >= len(prefix): continue # This case shouldn't happen due to high being len(freqs) if prefix[mid] >= k: ans = mid high = mid - 1 else: low = mid + 1 print(ans) if __name__ == "__main__": main()