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.items())])

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

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

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())])

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

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

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.items())])
remainder = max(0, len(A) - K)
print((sum(count_A[:remainder])))

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())])
remainder = max(0, len(A) - K)
print((sum(count_A[:remainder])))

-count_A = sorted([v for _, v in list(A.items())]) +count_A = sorted([v for v in list(A.values())])