N, K = map(int, input().split()) cards = list(map(int, input().split())) count = {} for card in cards: if card in count: count[card] += 1 else: count[card] = 1 sorted_counts = sorted(count.values()) types = 0 total = 0 for c in sorted_counts: total += 1 if total > K: break types += 1 print(types)