from collections import defaultdict a = defaultdict(int) n, k = map(int, input().split()) for i in list(map(int, input().split())): a[i] += 1 b = sorted(list(a.values())) m = len(b) ans = 0 while k > 0: ans += 1 k -= b[m - ans] print(ans)