from collections import defaultdict

n, k, *a = list(map(int, open(0).read().split()))

d = defaultdict(int)



for b in a:

    d[b] += 1



k = len(d) - k

ans = 0

for v in sorted(d.values()):

    if k <= 0:

        break

    ans += v

    k -= 1

print(ans)

from collections import defaultdict



n, k, *a = list(map(int, open(0).read().split()))

d = defaultdict(int)

for b in a:

    d[b] += 1



v = sorted(d.values())[::-1]



c = 0

for i in range(min(k, len(v))):

    c += v[i]



print((n - c))

from collections import defaultdict

n, k, *a = list(map(int, open(0).read().split()))
d = defaultdict(int)
for b in a:
    d[b] += 1
k = len(d) - k
ans = 0
for v in sorted(d.values()):
    if k <= 0:
        break
    ans += v
    k -= 1
print(ans)

from collections import defaultdict

n, k, *a = list(map(int, open(0).read().split()))
d = defaultdict(int)
for b in a:
    d[b] += 1
v = sorted(d.values())[::-1]
c = 0
for i in range(min(k, len(v))):
    c += v[i]
print((n - c))

-k = len(d) - k -ans = 0 -for v in sorted(d.values()): -    if k <= 0: -        break -    ans += v -    k -= 1 -print(ans) +v = sorted(d.values())[::-1] +c = 0 +for i in range(min(k, len(v))): +    c += v[i] +print((n - c))