N, K = map(int, input().split())
A = list(map(int, input().split()))

from collections import Counter
counted = Counter(A)
counted = list(counted.items())
counted.sort(key = lambda x:x[1], reverse = True)

card_count = 0
num_count = 0
for num, c in counted:
    num_count += 1
    card_count += c
    if card_count >= K:
        break
print(num_count)