from collections import Counter

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

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



c = Counter(a)

kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)



if n <= k:

    print((0))

else:

    ans = n

    for i in range(k):

        try:

            ans -= kv[i][1]

        except:

            pass

    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()))
c = Counter(a)
kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)
if n <= k:
    print((0))
else:
    ans = n
    for i in range(k):
        try:
            ans -= kv[i][1]
        except:
            pass
    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 - -(*a,) = list(map(int, input().split())) -c = Counter(a) -kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True) -if n <= k: -    print((0)) -else: -    ans = n -    for i in range(k): -        try: -            ans -= kv[i][1] -        except: -            pass -    print(ans) +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)