import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n,k = map(int,input().split()) a = list(map(int,input().split())) d = defaultdict(int) for i in range(n): d[a[i]] += 1 v = list(d.values()) ans = 0 v.sort() while k > 0: ans += 1 k -= v.pop() print(ans)