from collections import Counter N, K = map(int, input().split()) A = list(map(int, input().split())) c = Counter(A) ans = 0 for x in sorted(set(A), reverse=True): if ans + c[x] > K: break ans += c[x] print(ans)