n, k = map(int, input().split()) s = list(map(int, input().split())) s.sort(reverse=True) T = sorted(list(set(s)), reverse=True) ans = 0 for t in T: a = s.count(t) if ans + a <= k: ans += a else: break print(ans)