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: # https://atcoder.jp/contests/abc081/tasks/arc086_a
  import sys
  
  
  variety = 0  # 数字の種類
  element1 = 0
  
  
  def main():
      n, k = input().split()
      # N = int(n)
      K = int(k)
  
      numeric = input().split()  # サイズがわからなくてもこれでリストとして格納できる
      # list(map(int, numeric)) <-これもいいけど
      numeric = [int(x) for x in numeric]  # リストを返すなら内包表記の方が速い
  
      # 数字の種類の判定アルゴリズム
  
      numeric.sort()  # まずはソートをして
      # print(numeric)
  
      # まずnumeric内に何種類の数字があるかを判定。n種類ぶんのリスト(vary)を用意、１つずつ格納しておく
      vary = []  # 種類を格納
      TypeDetermination(numeric, vary)  # 何種類あるか判定
      # print(variety,vary)
  
      # そのリストを使って、その数が何個numericにあるかを数える。
      # 配列varyと同じ要素数.それぞれnumericに何個あったかを格納
      count = [0 for i in range(variety)]
      if variety > K:
          TypeOfNumber(vary, numeric, count)
      else:
          print(0)
          sys.exit()  # プログラムを終了させたい
  
      # varyをkeyに、countをvalueとして辞書を作成 <-varyをkeyに出来ていない
      # 辞書をcountで昇順ソート
      dicNum = {}
      makeDictionary(vary, count, dicNum)
      # print(dicNum)
  
      # ここで辞書の要素数がK個より大きい時、合計で何個の数字を入れ替えるか数える
      ballcount = 0
      ball = []
      if len(count) > K:
          ball = list(dicNum.values())
          # print(ball)
          for i in range(K):
              ball[i] = 0
  
      # print(ball)
      for i in range(len(ball)):
          ballcount += ball[i]
      print(ballcount)
  
  
  # #[Caution!!]-関数内でグローバル変数を使う時は引数に入れてはいけない！global hoge と関数内で宣言！！
  
  
  # numeric内に何種類の数字があるかを判定
  def TypeDetermination(numeric, vary):
      global element1, variety  # element1=0で初期化していますが、入力される数字は1<=x<=Nなので、OK
      for element in numeric:
          if element1 is not numeric:
              variety += 1
              element1 = element
              vary.append(element1)
  
  
  # TypeDeterminationでできたこと
  # n種類 is variety = n-1
  # vary = [1,2,4]など、1種類１つずつ格納！
  # ここから先、継続して使うのは配列varyと変数varietyと配列numeric
  
  
  # 3種類以上の時、それぞれ何個ずつなのかを数える
  # vary配列を使う
  def TypeOfNumber(vary, numeric, count):
      global variety
      N = variety
      for i in range(N):  # varyの中身、１つずつやっていく
          for j in range(len(numeric)):
              if vary[i] == numeric[j]:
                  count[i] += 1
  
  
  def makeDictionary(vary, count, dicNum):
      for i in range(len(count)):
          dicNum[vary[i]] = count[i]  # これがうまく行ってない
      sorted(dicNum.items(), key=lambda x: x[1])  # 降順でソート
  
  
  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"}]