from collections import Counter

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

A = Counter(list(map(int, input().split())))



A = sorted(list(dict(A).items()), key=lambda x:x[1])

ans = 0

if not len(A) <= K:

  n = len(A) - K

  ans = 0

  for i in range(n):

    ans += A[i][1]

print(ans)
from collections import Counter

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

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

ans = 0

a = sorted([i for i in list(a.values())], reverse=True)

if len(a) > k: ans = sum(a[k:])

print(ans)
from collections import Counter

N, K = list(map(int, input().split()))
A = Counter(list(map(int, input().split())))
A = sorted(list(dict(A).items()), key=lambda x: x[1])
ans = 0
if not len(A) <= K:
    n = len(A) - K
    ans = 0
    for i in range(n):
        ans += A[i][1]
print(ans)

from collections import Counter

n, k = list(map(int, input().split()))
a = Counter(list(map(int, input().split())))
ans = 0
a = sorted([i for i in list(a.values())], reverse=True)
if len(a) > k:
    ans = sum(a[k:])
print(ans)

-N, K = list(map(int, input().split())) -A = Counter(list(map(int, input().split()))) -A = sorted(list(dict(A).items()), key=lambda x: x[1]) +n, k = list(map(int, input().split())) +a = Counter(list(map(int, input().split()))) -if not len(A) <= K: -    n = len(A) - K -    ans = 0 -    for i in range(n): -        ans += A[i][1] +a = sorted([i for i in list(a.values())], reverse=True) +if len(a) > k: +    ans = sum(a[k:])