from collections import defaultdict n, K = map(int, input().split()) plst = list(map(int, input().split())) dd = defaultdict(int) for p in plst: dd[p] += 1 ans = 0 for k in sorted(dd.keys(), reverse = True): v = dd[k] if ans + v <= K: ans += v else: break print(ans)