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

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





d = {}

for a in A:

    if a in list(d.keys()):

        d[a] += 1

    else:

        d[a] = 1







ls = sorted(d.values())

ans = 0

for v in ls[:len(ls)-k]:

    ans += v

print(ans)

from collections import Counter

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

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

d = Counter(A)



ls = sorted(d.values())

ans = 0

for v in ls[:len(ls)-k]:

    ans += v

print(ans)

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
d = {}
for a in A:
    if a in list(d.keys()):
        d[a] += 1
    else:
        d[a] = 1
ls = sorted(d.values())
ans = 0
for v in ls[: len(ls) - k]:
    ans += v
print(ans)

from collections import Counter

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
d = Counter(A)
ls = sorted(d.values())
ans = 0
for v in ls[: len(ls) - k]:
    ans += v
print(ans)

+from collections import Counter + -d = {} -for a in A: -    if a in list(d.keys()): -        d[a] += 1 -    else: -        d[a] = 1 +d = Counter(A)