N,K = map(int,input().split()) a= list(map(int,input().split())) d = dict() for b in a: if b in d: d[b] += 1 else: d[b] = 1 l = sorted(d.values()) ans = 0 now = 0 while now < K: ans += 1 now += l.pop() print(ans)