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

nums=list(input().split())

used_balls=0

dict={}

for n in nums:

  if n not in list(dict.keys()):

    dict[n]=1

  else:

    dict[n]+=1

tmp=0

for d in sorted(list(dict.items()),key=lambda x: x[1],reverse=True):

  tmp+=1

  if tmp<=K:

    used_balls+=d[1]

  else:

    break

    

print((N-used_balls))

  
from collections import Counter

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

nums=list(input().split())

a=Counter(nums)

print((sum(sorted(list(a.values()), reverse=True)[K:])))
N, K = list(map(int, input().split()))
nums = list(input().split())
used_balls = 0
dict = {}
for n in nums:
    if n not in list(dict.keys()):
        dict[n] = 1
    else:
        dict[n] += 1
tmp = 0
for d in sorted(list(dict.items()), key=lambda x: x[1], reverse=True):
    tmp += 1
    if tmp <= K:
        used_balls += d[1]
    else:
        break
print((N - used_balls))

from collections import Counter

N, K = list(map(int, input().split()))
nums = list(input().split())
a = Counter(nums)
print((sum(sorted(list(a.values()), reverse=True)[K:])))

+from collections import Counter + -used_balls = 0 -dict = {} -for n in nums: -    if n not in list(dict.keys()): -        dict[n] = 1 -    else: -        dict[n] += 1 -tmp = 0 -for d in sorted(list(dict.items()), key=lambda x: x[1], reverse=True): -    tmp += 1 -    if tmp <= K: -        used_balls += d[1] -    else: -        break -print((N - used_balls)) +a = Counter(nums) +print((sum(sorted(list(a.values()), reverse=True)[K:])))