import collections



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

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

now_k=len(set(a))

d=now_k-k

arr=collections.Counter(a).most_common()

#print(arr)

b=sorted([arr[i][1] for i in range(now_k)])

#print(b)

cnt=now_k

cnt2=0

flg=0

for i in b:

  cnt-=1

  cnt2+=i

  if cnt==k:

    print(cnt2)

    flg=1

    break

if flg==0:

  print((0))
import collections



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

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



now_k=len(set(a))

d=now_k-k

arr=collections.Counter(a).most_common()

b=sorted([arr[i][1] for i in range(now_k)])

print((sum(b[:d])))
import collections

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
now_k = len(set(a))
d = now_k - k
arr = collections.Counter(a).most_common()
# print(arr)
b = sorted([arr[i][1] for i in range(now_k)])
# print(b)
cnt = now_k
cnt2 = 0
flg = 0
for i in b:
    cnt -= 1
    cnt2 += i
    if cnt == k:
        print(cnt2)
        flg = 1
        break
if flg == 0:
    print((0))

import collections

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
now_k = len(set(a))
d = now_k - k
arr = collections.Counter(a).most_common()
b = sorted([arr[i][1] for i in range(now_k)])
print((sum(b[:d])))

-# print(arr) -# print(b) -cnt = now_k -cnt2 = 0 -flg = 0 -for i in b: -    cnt -= 1 -    cnt2 += i -    if cnt == k: -        print(cnt2) -        flg = 1 -        break -if flg == 0: -    print((0)) +print((sum(b[:d])))