nums , types = list(map(int, input().split()))

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

array.sort()

type_count = 0

count = 0

result = 0

ary_count = []

array.append(1000000000)



for i in range (nums):

    if array[i] == array[i +1]:

        count += 1

    elif array[i] < array[i +1]:

        ary_count.append(count)

        type_count += 1

        count = 0



ary_count.sort()



if type_count > types:

    for i in range(type_count - types):

        result += ary_count[i]+1

print(result)
from collections import Counter

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

ary = Counter(list(map(int,input().split())))

if len(list(ary.keys())) <= k:print((0));exit()

print((sum(sorted(ary.values())[:len(list(ary.keys()))-k])))
nums, types = list(map(int, input().split()))
array = list(map(int, input().split()))
array.sort()
type_count = 0
count = 0
result = 0
ary_count = []
array.append(1000000000)
for i in range(nums):
    if array[i] == array[i + 1]:
        count += 1
    elif array[i] < array[i + 1]:
        ary_count.append(count)
        type_count += 1
        count = 0
ary_count.sort()
if type_count > types:
    for i in range(type_count - types):
        result += ary_count[i] + 1
print(result)

from collections import Counter

n, k = list(map(int, input().split()))
ary = Counter(list(map(int, input().split())))
if len(list(ary.keys())) <= k:
    print((0))
    exit()
print((sum(sorted(ary.values())[: len(list(ary.keys())) - k])))

-nums, types = list(map(int, input().split())) -array = list(map(int, input().split())) -array.sort() -type_count = 0 -count = 0 -result = 0 -ary_count = [] -array.append(1000000000) -for i in range(nums): -    if array[i] == array[i + 1]: -        count += 1 -    elif array[i] < array[i + 1]: -        ary_count.append(count) -        type_count += 1 -        count = 0 -ary_count.sort() -if type_count > types: -    for i in range(type_count - types): -        result += ary_count[i] + 1 -print(result) +from collections import Counter + +n, k = list(map(int, input().split())) +ary = Counter(list(map(int, input().split()))) +if len(list(ary.keys())) <= k: +    print((0)) +    exit() +print((sum(sorted(ary.values())[: len(list(ary.keys())) - k])))