from collections import Counter N, K = map(int, input().split()) P = Counter(map(int, input().split())) cnt = 0 for x in sorted(P, reverse=True): if cnt + P[x] > K: print(cnt) exit() cnt += P[x] print(N)