n,k = list(map(int, input().split()))

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

d = {}

for a in A:

  if a in d:

    d[a] +=1

  else:

    d[a] =1

    

d =sorted(d.values())

if len(d) > k:

  ans = 0

  for i in range(len(d)-k):

    ans += d[i]

  print(ans)

else:

  print((0))

n,k = list(map(int,input().split()))

a = [int(i) for i in input().split() ]



d = {}

for i in a:

  if i in d:

    d[i] += 1

  else:

    d[i] = 1

    

    

d = sorted(d.values())

if len(d) > k:

  ans = 0

  for i in range(len(d)-k):

    ans += d[i]

  print(ans)

else:

  print((0))

  
n, k = list(map(int, input().split()))
A = [int(x) for x in input().split()]
d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
d = sorted(d.values())
if len(d) > k:
    ans = 0
    for i in range(len(d) - k):
        ans += d[i]
    print(ans)
else:
    print((0))

n, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
d = sorted(d.values())
if len(d) > k:
    ans = 0
    for i in range(len(d) - k):
        ans += d[i]
    print(ans)
else:
    print((0))

-A = [int(x) for x in input().split()] +a = [int(i) for i in input().split()] -for a in A: -    if a in d: -        d[a] += 1 +for i in a: +    if i in d: +        d[i] += 1 -        d[a] = 1 +        d[i] = 1