N, K = list(map(int, input().split()))

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



buckets = {}

for i in A:

    if i in buckets:

        buckets[i] += 1

    else:

        buckets[i] = 1



kinds = sorted(buckets.values())

count = len(kinds)

if K < count:

    mini = 0

    for i in kinds:

        mini += i

        count -= 1

        if count <= K:

            break

    print(mini)

else:

    print((0))
N, K = list(map(int, input().split()))

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



buckets = {}

for i in A:

    if i in buckets:

        buckets[i] += 1

    else:

        buckets[i] = 1



kinds = sorted(list(buckets.values()), reverse=True)

if K < len(kinds):

    mini = N-sum([kinds[i] for i in range(K)])

    print(mini)

else:

    print((0))
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
buckets = {}
for i in A:
    if i in buckets:
        buckets[i] += 1
    else:
        buckets[i] = 1
kinds = sorted(buckets.values())
count = len(kinds)
if K < count:
    mini = 0
    for i in kinds:
        mini += i
        count -= 1
        if count <= K:
            break
    print(mini)
else:
    print((0))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
buckets = {}
for i in A:
    if i in buckets:
        buckets[i] += 1
    else:
        buckets[i] = 1
kinds = sorted(list(buckets.values()), reverse=True)
if K < len(kinds):
    mini = N - sum([kinds[i] for i in range(K)])
    print(mini)
else:
    print((0))

-kinds = sorted(buckets.values()) -count = len(kinds) -if K < count: -    mini = 0 -    for i in kinds: -        mini += i -        count -= 1 -        if count <= K: -            break +kinds = sorted(list(buckets.values()), reverse=True) +if K < len(kinds): +    mini = N - sum([kinds[i] for i in range(K)])