import sys readline=sys.stdin.readline from collections import Counter N,K=map(int,readline().split()) A=list(map(int,readline().split())) C=Counter(A) lst=[(c,a) for a,c in C.items()] lst.sort(reverse=True) A=[] for c,a in lst: A+=[a]*c ans=len(set(A[:K])) print(ans)