N,K=map(int, input().split()) cards=list(map(int, input().split())) counts = [0]*(N + 1) for i in range(N): counts[cards[i]]+=1 counts.sort(reverse=True) total=0 num_types=0 for count in counts: if total>=K: break total += count num_types+=1 print(num_types)