from collections import Counter n, k = map(int, input().split()) p = list(map(int, input().split())) c = list(reversed(sorted(Counter(p).items()))) t = 0 for ka, x in c: if t + x > k: break t += x print(t)