import sys, math input = lambda: sys.stdin.readline()[:-1] def MI(): return map(int, input().split()) inf = 10**18 from collections import * n,k = MI() a = list(MI()) cnt = Counter(a) cnt = sorted(cnt.items(), key=lambda x:x[1], reverse=True) now = 0 ans = 0 for key, value in cnt: if now >= k: break now += value ans += 1 print(ans)