import collections

from collections import OrderedDict

count=0

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

ball=list(map(str,input().split()))

c=sorted(collections.Counter(ball).values())

n=len(c)-K

if n==0:

    print(count)

else:

    for i in range(n):

        count+=c[i]

    print(count)
import collections

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

c=sorted(collections.Counter(list(map(str,input().split()))).values())

print((sum(c[:-K])))
import collections
from collections import OrderedDict

count = 0
N, K = list(map(int, input().split()))
ball = list(map(str, input().split()))
c = sorted(collections.Counter(ball).values())
n = len(c) - K
if n == 0:
    print(count)
else:
    for i in range(n):
        count += c[i]
    print(count)

import collections

N, K = list(map(int, input().split()))
c = sorted(collections.Counter(list(map(str, input().split()))).values())
print((sum(c[:-K])))

-from collections import OrderedDict -count = 0 -ball = list(map(str, input().split())) -c = sorted(collections.Counter(ball).values()) -n = len(c) - K -if n == 0: -    print(count) -else: -    for i in range(n): -        count += c[i] -    print(count) +c = sorted(collections.Counter(list(map(str, input().split()))).values()) +print((sum(c[:-K])))