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

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

d = {}

for i in range(n):

    if a[i] in d:

        d[a[i]] = d[a[i]] + 1

    else:

        d[a[i]] = 1



ans = 0

diverse = len(d)

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



for i in range(len(d)):

    if diverse > k:

        ans += d[i][1]

        diverse -= 1

    else:

        break

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

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

cnt = [0] * 2000001

for i in range(n):

    cnt[a[i]] += 1

cnt.sort(reverse = True)

print((n - sum(cnt[:k])))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] = d[a[i]] + 1
    else:
        d[a[i]] = 1
ans = 0
diverse = len(d)
d = sorted(list(d.items()), key=lambda x: x[1])
for i in range(len(d)):
    if diverse > k:
        ans += d[i][1]
        diverse -= 1
    else:
        break
print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = [0] * 2000001
for i in range(n):
    cnt[a[i]] += 1
cnt.sort(reverse=True)
print((n - sum(cnt[:k])))

-d = {} +cnt = [0] * 2000001 -    if a[i] in d: -        d[a[i]] = d[a[i]] + 1 -    else: -        d[a[i]] = 1 -ans = 0 -diverse = len(d) -d = sorted(list(d.items()), key=lambda x: x[1]) -for i in range(len(d)): -    if diverse > k: -        ans += d[i][1] -        diverse -= 1 -    else: -        break -print(ans) +    cnt[a[i]] += 1 +cnt.sort(reverse=True) +print((n - sum(cnt[:k])))