import collections,sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N,K = LI()

A = collections.Counter(LI())

count_A = sorted([v for v in list(A.values())])

surplus = max(0,len(A)-K)

print((sum(count_A[:surplus])))

import collections,sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N,K = LI()

A = collections.Counter(LI())

value_A = sorted(A.values())

surplus = max(0,len(A)-K)

print((sum(value_A[:surplus])))

import collections, sys


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N, K = LI()
A = collections.Counter(LI())
count_A = sorted([v for v in list(A.values())])
surplus = max(0, len(A) - K)
print((sum(count_A[:surplus])))

import collections, sys


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N, K = LI()
A = collections.Counter(LI())
value_A = sorted(A.values())
surplus = max(0, len(A) - K)
print((sum(value_A[:surplus])))

-count_A = sorted([v for v in list(A.values())]) +value_A = sorted(A.values()) -print((sum(count_A[:surplus]))) +print((sum(value_A[:surplus])))