from collections import Counter



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

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

cnt = Counter(a).most_common()[::-1]



ans = 0

if k < len(cnt):

  for k, v in cnt[:len(cnt) - k]:

    ans += v



print(ans)
from collections import Counter

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

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



cnt = Counter(a)

div = max(0, len(cnt) - k)



if div != 0:

  l = sorted(cnt.values())

  print((sum(l[:div])))

  

else:

  print((0))

from collections import Counter

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = Counter(a).most_common()[::-1]
ans = 0
if k < len(cnt):
    for k, v in cnt[: len(cnt) - k]:
        ans += v
print(ans)

from collections import Counter

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = Counter(a)
div = max(0, len(cnt) - k)
if div != 0:
    l = sorted(cnt.values())
    print((sum(l[:div])))
else:
    print((0))

-cnt = Counter(a).most_common()[::-1] -ans = 0 -if k < len(cnt): -    for k, v in cnt[: len(cnt) - k]: -        ans += v -print(ans) +cnt = Counter(a) +div = max(0, len(cnt) - k) +if div != 0: +    l = sorted(cnt.values()) +    print((sum(l[:div]))) +else: +    print((0))