N, K = [int(x) for x in input().split()]

A_lst = [int(x) for x in input().split()]

dict = {}

for i in A_lst:

    if not i in list(dict.keys()):

        dict[i] = 1

    else:

        dict[i] += 1



lst = []

for i in list(dict.keys()):

    lst.append(dict[i])

lst.sort()

k = len(lst)

cnt = 0



for i in lst:

    if k <= K:

        break

    else:

        k -= 1

        cnt += i



print(cnt)

N, K = [int(x) for x in input().split()]

A_lst = [int(x) for x in input().split()]

dict = {}

for i in A_lst:

    if not i in list(dict.keys()):

        dict[i] = 1

    else:

        dict[i] += 1



val_lst = list(dict.values())

val_lst.sort()

k = len(val_lst)

cnt = 0



for i in val_lst:

    if k <= K:

        break

    else:

        k -= 1

        cnt += i



print(cnt)

N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
dict = {}
for i in A_lst:
    if not i in list(dict.keys()):
        dict[i] = 1
    else:
        dict[i] += 1
lst = []
for i in list(dict.keys()):
    lst.append(dict[i])
lst.sort()
k = len(lst)
cnt = 0
for i in lst:
    if k <= K:
        break
    else:
        k -= 1
        cnt += i
print(cnt)

N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
dict = {}
for i in A_lst:
    if not i in list(dict.keys()):
        dict[i] = 1
    else:
        dict[i] += 1
val_lst = list(dict.values())
val_lst.sort()
k = len(val_lst)
cnt = 0
for i in val_lst:
    if k <= K:
        break
    else:
        k -= 1
        cnt += i
print(cnt)

-lst = [] -for i in list(dict.keys()): -    lst.append(dict[i]) -lst.sort() -k = len(lst) +val_lst = list(dict.values()) +val_lst.sort() +k = len(val_lst) -for i in lst: +for i in val_lst: