# ABC081C - Not so Diverse (ARC086C)

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

lst = sorted(list(map(int, input().rstrip().split())))

dic = {}

for i in lst:

    if i not in dic:

        dic[i] = 1

    else:

        dic[i] += 1



cnt = sorted([i for i in list(dic.values())], reverse=True)

ans = 0

for i in range(len(cnt)):

    if k > 0:

        k -= 1

        continue

    ans += cnt[i]

print(ans)
# ARC086C - Not so Diverse (ABC081C)

from collections import Counter





def main():

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

    A = sorted(list(Counter(list(map(int, input().split()))).values()), reverse=True)

    print((sum(A[k:])))





if __name__ == "__main__":

    main()
# ABC081C - Not so Diverse (ARC086C)
n, k = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())))
dic = {}
for i in lst:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1
cnt = sorted([i for i in list(dic.values())], reverse=True)
ans = 0
for i in range(len(cnt)):
    if k > 0:
        k -= 1
        continue
    ans += cnt[i]
print(ans)

# ARC086C - Not so Diverse (ABC081C)
from collections import Counter


def main():
    n, k = list(map(int, input().rstrip().split()))
    A = sorted(list(Counter(list(map(int, input().split()))).values()), reverse=True)
    print((sum(A[k:])))


if __name__ == "__main__":
    main()

-# ABC081C - Not so Diverse (ARC086C) -n, k = list(map(int, input().rstrip().split())) -lst = sorted(list(map(int, input().rstrip().split()))) -dic = {} -for i in lst: -    if i not in dic: -        dic[i] = 1 -    else: -        dic[i] += 1 -cnt = sorted([i for i in list(dic.values())], reverse=True) -ans = 0 -for i in range(len(cnt)): -    if k > 0: -        k -= 1 -        continue -    ans += cnt[i] -print(ans) +# ARC086C - Not so Diverse (ABC081C) +from collections import Counter + + +def main(): +    n, k = list(map(int, input().rstrip().split())) +    A = sorted(list(Counter(list(map(int, input().split()))).values()), reverse=True) +    print((sum(A[k:]))) + + +if __name__ == "__main__": +    main()