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

a = input().split()



d = dict()

for i in a:

    d[i] = d.get(i, 0) + 1

d_sorted = sorted(d.values())

knd = len(set(a))##種類数

print((sum(d_sorted[:knd - k])))    
n, k = list(map(int, input().split()))

a = input().split()

b = dict()

for i in a:

    b[i] = b.get(i, 0) + 1

print((sum(sorted(b.values())[:-k])))
n, k = list(map(int, input().split()))
a = input().split()
d = dict()
for i in a:
    d[i] = d.get(i, 0) + 1
d_sorted = sorted(d.values())
knd = len(set(a))  ##種類数
print((sum(d_sorted[: knd - k])))

n, k = list(map(int, input().split()))
a = input().split()
b = dict()
for i in a:
    b[i] = b.get(i, 0) + 1
print((sum(sorted(b.values())[:-k])))

-d = dict() +b = dict() -    d[i] = d.get(i, 0) + 1 -d_sorted = sorted(d.values()) -knd = len(set(a))  ##種類数 -print((sum(d_sorted[: knd - k]))) +    b[i] = b.get(i, 0) + 1 +print((sum(sorted(b.values())[:-k])))