from collections import Counter N, K = map(int, input().split()) A = list(map(int, input().split())) C = Counter(A) S = sorted(list(set(A)), key=lambda x: -C[x]) ans = 0 ct = 0 for s in S: if ct >= K: break ct += C[s] ans += 1 print(ans)