N, K = map(int, input().split()) A = list(map(int, input().split())) cnt = [0]*(N + 1) for a in A: cnt[a] += 1 data = [] for i in range(1, N + 1): if cnt[i] != 0: data.append((cnt[i], i)) data.sort() total = 0 distinct_nums = 0 while data: c, num = data.pop() if total + c < K: distinct_nums += 1 total += c else: distinct_nums += 1 break print(distinct_nums)