from itertools import groupby n, k = map(int, input().split()) ans = 0 for _, l in groupby(sorted(map(int, input().split()), reverse=True)): x = len(list(l)) if x > k: break ans += x k -= x print(ans)