n,k=map(int,input().split()) l=list(map(int,input().split())) from collections import defaultdict d=defaultdict(int) for i in range(n): d[l[i]]+=1 ans=[] for k,v in d.items(): ans.append((k,v)) ans.sort(key=lambda x: -x[1]) cnt=0 while k>0: k-= ans[cnt][1] cnt+=1 else: print(cnt)