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

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



d = {}

for a in A:

  if(a not in d):

    d[a] = 1

  else:

    d[a] += 1

if(len(d) <= K):

  print((0))

else:

  tmp = sorted(list(d.items()), key = lambda x: -x[1])[K:]

  print((sum(t[1] for t in tmp)))
N, K = list(map(int,input().split()))

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



d = {}

for a in A:

  if(a not in d):

    d[a] = 1

  else:

    d[a] += 1



print((sum(sorted(d.values())[:-K])))
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
d = {}
for a in A:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
if len(d) <= K:
    print((0))
else:
    tmp = sorted(list(d.items()), key=lambda x: -x[1])[K:]
    print((sum(t[1] for t in tmp)))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
d = {}
for a in A:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
print((sum(sorted(d.values())[:-K])))

-if len(d) <= K: -    print((0)) -else: -    tmp = sorted(list(d.items()), key=lambda x: -x[1])[K:] -    print((sum(t[1] for t in tmp))) +print((sum(sorted(d.values())[:-K])))