from collections import Counter



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

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

d = Counter(a)

d = d.most_common()

ans = 0



for i in range(len(d) - k):

    ans += d[-i - 1][1]



print(ans)
from collections import Counter



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

a = input().split()

d = sorted(Counter(a).values())

ans = 0



for i in range(len(d) - k):

    ans += d[i]



print(ans)
from collections import Counter

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
d = Counter(a)
d = d.most_common()
ans = 0
for i in range(len(d) - k):
    ans += d[-i - 1][1]
print(ans)

from collections import Counter

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

-a = list(map(int, input().split())) -d = Counter(a) -d = d.most_common() +a = input().split() +d = sorted(Counter(a).values()) -    ans += d[-i - 1][1] +    ans += d[i]