import os,re,sys,operator,math

from collections import Counter,deque

from operator import itemgetter

from itertools import accumulate,combinations,groupby

from sys import stdin,setrecursionlimit

from copy import deepcopy

import heapq



setrecursionlimit(10**6)

n,k=list(map(int,stdin.readline().rstrip().split()))

a=[int(i) for i in stdin.readline().rstrip().split()]

t=deque(Counter(a).most_common())

ans=0

while len(t)>k:

    now=t.pop()

    ans+=now[1]

print(ans)


from collections import Counter

n,k=list(map(int,input().split()))

a=[int(i) for i in input().split()]



c=Counter(a).most_common()

c.sort(key=lambda x: x[1])

#print(c)

l=len(c)

print((sum(c[i][1] for i in range(l-k))))
import os, re, sys, operator, math
from collections import Counter, deque
from operator import itemgetter
from itertools import accumulate, combinations, groupby
from sys import stdin, setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
n, k = list(map(int, stdin.readline().rstrip().split()))
a = [int(i) for i in stdin.readline().rstrip().split()]
t = deque(Counter(a).most_common())
ans = 0
while len(t) > k:
    now = t.pop()
    ans += now[1]
print(ans)

from collections import Counter

n, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
c = Counter(a).most_common()
c.sort(key=lambda x: x[1])
# print(c)
l = len(c)
print((sum(c[i][1] for i in range(l - k))))

-import os, re, sys, operator, math -from collections import Counter, deque -from operator import itemgetter -from itertools import accumulate, combinations, groupby -from sys import stdin, setrecursionlimit -from copy import deepcopy -import heapq +from collections import Counter -setrecursionlimit(10**6) -n, k = list(map(int, stdin.readline().rstrip().split())) -a = [int(i) for i in stdin.readline().rstrip().split()] -t = deque(Counter(a).most_common()) -ans = 0 -while len(t) > k: -    now = t.pop() -    ans += now[1] -print(ans) +n, k = list(map(int, input().split())) +a = [int(i) for i in input().split()] +c = Counter(a).most_common() +c.sort(key=lambda x: x[1]) +# print(c) +l = len(c) +print((sum(c[i][1] for i in range(l - k))))