from heapq import * from collections import * N, K = map(int, input().split()) A = list(map(int, input().split())) H = [] D = defaultdict(int) for a in A: D[a] += 1 for k, v in D.items(): heappush(H, (-v, k)) ans = set() for _ in range(K): v, k = heappop(H) v = -v v -= 1 ans.add(k) if v: heappush(H, (-v, k)) print(len(ans))