import collections

import sys

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

a=[]

a=collections.Counter( list(map(int,input().split())) )

b=sorted(list(a.items()), key=lambda x:x[1])



if len(b)=="K":

	print(0)

	sys.exit()

else:

	sum=0

	for i in range(len(b)-K):

		sum+=b[i][1]

	else:

		print(sum)

import sys

from collections import Counter

N,K=list(map(int, sys.stdin.readline().split()))

A=list(map(int, sys.stdin.readline().split()))

C=Counter(A)

C=list(C.values())

C.sort()

print(sum(C[:-1*K]))
import collections
import sys

N, K = list(map(int, input().split()))
a = []
a = collections.Counter(list(map(int, input().split())))
b = sorted(list(a.items()), key=lambda x: x[1])
if len(b) == "K":
    print(0)
    sys.exit()
else:
    sum = 0
    for i in range(len(b) - K):
        sum += b[i][1]
    else:
        print(sum)

import sys
from collections import Counter

N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
C = Counter(A)
C = list(C.values())
C.sort()
print(sum(C[: -1 * K]))

-import collections +from collections import Counter -N, K = list(map(int, input().split())) -a = [] -a = collections.Counter(list(map(int, input().split()))) -b = sorted(list(a.items()), key=lambda x: x[1]) -if len(b) == "K": -    print(0) -    sys.exit() -else: -    sum = 0 -    for i in range(len(b) - K): -        sum += b[i][1] -    else: -        print(sum) +N, K = list(map(int, sys.stdin.readline().split())) +A = list(map(int, sys.stdin.readline().split())) +C = Counter(A) +C = list(C.values()) +C.sort() +print(sum(C[: -1 * K]))