output_description: Print the minimum number of balls that Takahashi needs to rewrite the integers
  on them.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      A_1 A_2 ... A_N
attempt: import sys
  
  
  ## io ##
  def IS():
      return sys.stdin.readline().rstrip()
  
  
  def II():
      return int(IS())
  
  
  def MII():
      return list(map(int, IS().split()))
  
  
  def MIIZ():
      return list(map(lambda x: x - 1, MII()))
  
  
  ## dp ##
  INIT_VAL = 0
  
  
  def DD2(d1, d2):
      return [[INIT_VAL] * d2 for _ in range(d1)]
  
  
  def DD3(d1, d2, d3):
      return [DD2(d2, d3) for _ in range(d1)]
  
  
  ## math ##
  def to_bin(x: int) -> str:
      return format(x, "b")  # rev => int(res, 2)
  
  
  def to_oct(x: int) -> str:
      return format(x, "o")  # rev => int(res, 8)
  
  
  def to_hex(x: int) -> str:
      return format(x, "x")  # rev => int(res, 16)
  
  
  MOD = 10**9 + 7
  
  
  def divc(x, y) -> int:
      return -(-x // y)
  
  
  def divf(x, y) -> int:
      return x // y
  
  
  def gcd(x, y):
      while y:
          x, y = y, x % y
      return x
  
  
  def lcm(x, y):
      return x * y // gcd(x, y)
  
  
  def enumerate_divs(n):
      """Return a tuple list of divisor of n"""
      return [(i, n // i) for i in range(1, int(n**0.5) + 1) if n % i == 0]
  
  
  def get_primes(MAX_NUM=10**3):
      """Return a list of prime numbers n or less"""
      is_prime = [True] * (MAX_NUM + 1)
      is_prime[0] = is_prime[1] = False
      for i in range(2, int(MAX_NUM**0.5) + 1):
          if not is_prime[i]:
              continue
          for j in range(i * 2, MAX_NUM + 1, i):
              is_prime[j] = False
      return [i for i in range(MAX_NUM + 1) if is_prime[i]]
  
  
  ## libs ##
  from itertools import accumulate as acc
  from collections import deque, Counter
  from heapq import heapify, heappop, heappush
  from bisect import bisect_left
  
  # ======================================================#
  
  
  def main():
      n, k = MII()
      aa = Counter(MII())
      c = aa.most_common()[-(len(aa) - k) :]
      print(sum([ci[1] for ci in c]))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.
  
  He would like to rewrite the integer on some balls so that there are at most K
  different integers written on the N balls.
  
  Find the minimum number of balls that Takahashi needs to rewrite the integers
  on them.
samples: [{"input": "5 2\n    1 1 2 2 5", "output": "1\n    \n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two\ndifferent integers written on the balls: 1 and 2. On the other hand, it is not\npossible to rewrite the integers on zero balls so that there are at most two\ndifferent integers written on the balls, so we should print 1.\n\n* * *"}, {"input": "4 4\n    1 1 2 2", "output": "0\n    \n\nAlready in the beginning, there are two different integers written on the\nballs, so we do not need to rewrite anything.\n\n* * *"}, {"input": "10 3\n    5 1 3 2 4 1 1 2 3 4", "output": "3"}]