N,K=map(int,input().split()) A=list(map(int,input().split())) CardDict={} for i in range(N): if A[i] in CardDict: CardDict[A[i]]+=1 else: CardDict[A[i]]=1 Asorted=list(CardDict.values()) Asorted.sort(reverse=True) count=0 for i in range(len(Asorted)): if K-Asorted[i]>=0: K-=Asorted[i] count+=1 print(count)