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.

-----Constraints-----
 - 1 \leq K \leq N \leq 200000
 - 1 \leq A_i \leq N
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N K
A_1 A_2 ... A_N

-----Output-----
Print the minimum number of balls that Takahashi needs to rewrite the integers on them.

-----Sample Input-----
5 2
1 1 2 2 5

-----Sample Output-----
1

For example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.
On the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.
[{"code": "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nfrom collections import Counter\ndic=Counter(a)\ndic=sorted(list(dic.items()),key=lambda x:x[1])\n\nans=0\ncnt=0\nl=max(len(dic)-k,0)\nfor i in dic:\n  if cnt==l:\n    break\n  ans=ans+i[1]\n  cnt=cnt+1\nprint(ans)\n", "passed": true, "time": 0.31, "memory": 14140.0, "status": "done"}, {"code": "N, K = map(int,input().split())\nA = list(map(int,input().split()))\n\nimport collections\n\ncA = collections.Counter(A)\n\nsorted_ls = sorted(list(cA.values()))\nsum_ls = sum(sorted_ls)\n\n\nif len(sorted_ls)>K:\n  print(sum(sorted_ls[:len(sorted_ls)-K]))\nelse:\n  print(0)", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "import collections as c\nn,k=map(int,input().split());a=c.Counter(map(int,input().split()))\nprint([0,sum(sorted([*a.values()])[:len(a)-k])][len(a)>k])", "passed": true, "time": 0.21, "memory": 14108.0, "status": "done"}, {"code": "from collections import Counter\n\nn, k = list(map(int, input().split()))\nctr = Counter(list(map(int, input().split())))\n\naa = sorted(list(ctr.items()), key=lambda x: x[1])\nif len(aa) <= k:\n    print((0))\nelse:\n    print((sum([x[1] for x in aa[:len(aa) - k]])))\n", "passed": true, "time": 0.2, "memory": 14336.0, "status": "done"}, {"code": "from collections import Counter\n\nn, k = map(int, input().split())\ns = list(map(int, input().split()))\n\nnum = Counter(s)\n\n\nif len(num) <= k:\n    print(0)\n\nelse:\n    cnt = len(num) - k\n    ans = 0\n    i = 0\n    for v in sorted(num.values()):\n        if cnt == i:\n            break\n        ans += v\n        i += 1\n\n    print(ans)", "passed": true, "time": 1.82, "memory": 14240.0, "status": "done"}, {"code": "import collections\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nvalues,counts = zip(*collections.Counter(A).most_common())\nans = 0\n\nB = counts[K:]\n\nfor i in B:\n    ans += i\nprint(ans)", "passed": true, "time": 0.17, "memory": 14328.0, "status": "done"}, {"code": "from collections import Counter, deque\n\n_, k = map(int, input().split())\na = [int(i) for i in input().split()]\n\nans = 0\nd = deque(sorted(Counter(a).values()))\nwhile k < len(d):\n    ans += d.popleft()\nelse:\n    print(ans)", "passed": true, "time": 0.38, "memory": 14156.0, "status": "done"}, {"code": "import collections\n\nn, k = map(int,input().split())\na = list(map(int, input().split()))\n\nc = collections.Counter(a)\ni = 0\ncnt = 0\nfor key, val in sorted(c.items(), key=lambda x: -x[1]):\n    # print(key, val)\n    cnt += val\n    i += 1\n    if i >= k:\n        break\n        \nprint(n - cnt)", "passed": true, "time": 0.22, "memory": 14308.0, "status": "done"}, {"code": "import operator\nn,k=[int(_) for _ in input().split()]\nD=dict()\nA=[int(_) for _ in input().split()]\nfor _ in range(n):\n    if A[_] in D:\n        D[A[_]]+=1\n    else:\n        D[A[_]]=1\nD=dict(sorted(list(D.items()), key=operator.itemgetter(1),reverse=True))\nc=0\ni=0\nfor _ in D:\n    if i>=k:\n        c+=D[_]\n    i+=1\nprint(c)\n", "passed": true, "time": 0.28, "memory": 14240.0, "status": "done"}, {"code": "N,K = map(int,input().split())\nA = list(map(int,input().split()))\ndic = {}\n\nfor a in A:\n  if a in dic.keys():\n    dic[a] += 1\n  else:\n    dic[a] = 1\n    \ndic = sorted(dic.items(), key = lambda x:x[1], reverse=True)\n\nans = 0\nfor (i,j) in dic[K:]:\n  ans += j\n  \nprint(ans)", "passed": true, "time": 0.15, "memory": 14096.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nl = list(map(int, input().split()))\nfreq = [0]*(n+1)\nfor i in l:\n    freq[i]+=1\nfreq.sort()\nvf = len(freq) - k if len(freq)> k else 0\nprint(sum(freq[:vf]))", "passed": true, "time": 0.22, "memory": 14240.0, "status": "done"}, {"code": "from collections import Counter\nN, K = map(int, input().split())\nA = Counter(input().split())\n\nprint(sum(sorted(A.values(), reverse=True)[K:]))", "passed": true, "time": 0.14, "memory": 14368.0, "status": "done"}, {"code": "from collections import Counter\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n# N=O(10^5)\u306a\u306e\u3067\u3001O(N)\u3067\u89e3\u304f\n# ABC-155-C-Poll \u306e\u985e\u984c\n# \u65b9\u91dd\uff1a\u5404\u6570\u5b57\u306e\u51fa\u73fe\u56de\u6570\u3092\u6570\u3048\u308b\n\n# Counter(\u30ea\u30b9\u30c8) \u306f\u8f9e\u66f8\u578b\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3042\u308a\u3001\u30ad\u30fc\u306b\u8981\u7d20\u30fb\u5024\u306b\u51fa\u73fe\u56de\u6570\u3068\u3044\u3046\u5f62\u5f0f\n# Counter(\u30ea\u30b9\u30c8).most_common() \u306f(\u8981\u7d20, \u51fa\u73fe\u56de\u6570)\u3068\u3044\u3046\u30bf\u30d7\u30eb\u3092\u51fa\u73fe\u56de\u6570\u9806\u306b\u4e26\u3079\u305f\u30ea\u30b9\u30c8\nA = Counter(A).most_common()\n\n# \u51fa\u73fe\u56de\u6570\u306e\u5927\u304d\u3044\u65b9\u304b\u3089K\u500b\u306f\u305d\u306e\u307e\u307e\u306b\u3057\u3066\u304a\u304f(=\u5909\u3048\u306a\u3044\u500b\u6570\uff09\n# \u5909\u3048\u308b\u500b\u6570\u306f\u3001N-(\u5909\u3048\u306a\u3044\u500b\u6570)\ns = 0\nfor i in range(min(K, len(A))):\n  s += A[i][1]\n  \nprint(N-s)", "passed": true, "time": 0.2, "memory": 14024.0, "status": "done"}, {"code": "N,K=map(int,input().split())\nA={}\nfor i in input().split():\n  A[i]=A.get(i,0)+1\nA=sorted(A.values())\nprint(sum(A[0:len(A)-K]))", "passed": true, "time": 0.14, "memory": 14344.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nan = [int(num) for num in input().split()]\n\nkind = {}\nfor a in an:\n  if not a in kind:\n    kind[a] = 1\n  else :\n    kind[a] += 1\n\nsortedKind = sorted(list(kind.items()), key=lambda x:x[1])    \n\nif len(sortedKind) > k:\n  count = 0\n  for check in sortedKind[:len(sortedKind)-k]:\n    count += check[1]\n  print(count)\nelse :\n  print((0))\n", "passed": true, "time": 0.15, "memory": 14332.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nimport collections\n\na=collections.Counter(a)\nkey=list(a.values())\nkey.sort()\nans=sum(key[:len(key)-k])\nprint(ans)\n", "passed": true, "time": 0.31, "memory": 14080.0, "status": "done"}, {"code": "n,k  =map(int, input().split())\nA = list(map(int, input().split()))\n\nd = {}\nfor a in A:\n    d[a] = d.get(a, 0) + 1\n\nif len(d) <= k:\n    print(0)\nelse:\n    d = sorted(d.values())\n    cnt = 0\n    for i in range(len(d)-k):\n        cnt += d[i]\n    print(cnt)", "passed": true, "time": 0.15, "memory": 14156.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nl = list(map(int, input().split()))\nfreq = [0]*(n+1)\nfor i in l:\n    freq[i]+=1\nfreq.sort()\nprint(sum(freq[:n-k+1]))", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nfrom collections import Counter\nac=sorted(list(Counter(a).values()))\nle=len(ac)\nif le<=k:\n  print((0))\nelse:\n  count=0\n  for i in range(le-k):\n    count+=ac[i]\n  print(count)\n", "passed": true, "time": 0.14, "memory": 14368.0, "status": "done"}, {"code": "N, K = map(int, input().split())\na = list(map(int,input().split()))\n\na_dict = {}\n\nfor i in range(N):\n    if a[i] not in a_dict.keys():\n        a_dict[a[i]] = 1\n    else:\n        a_dict[a[i]] += 1\n\nans = 0\nif len(a_dict) <= K:\n    print(ans)\nelse:\n    sort_a_dict_list = sorted(a_dict.items(), key=lambda x:x[1])\n\n    for j in range(len(a_dict) - K):\n        ans += sort_a_dict_list[j][1]\n    print(ans)", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "nk = list(map(int, input().split()))\nn, k = nk[0], nk[1]\nballs = {}\nfor ball in list(map(int, input().split())):\n    if ball in balls:\n        balls[ball] += 1\n    else:\n        balls[ball] = 1\n\n\nsize = len(list(balls.keys()))\nswap_balls = list([(x[1], x[0]) for x in list(balls.items())])\nswap_balls.sort()\ncount = 0\n\nfor ball_count, ball_number in swap_balls:\n    if size <= k:\n        break\n    else:\n        count += ball_count\n        size -= 1\n\nprint(count)\n", "passed": true, "time": 0.19, "memory": 14292.0, "status": "done"}, {"code": "N, K = input().split()\nA = dict()\nfor i in input().split():\n  if int(i) in A:\n    A[int(i)]+=1\n  else:\n    A[int(i)]=1\n\nhoge = []\nfor i in A.values():\n  hoge.append(i)\nhoge.sort()\n\nsum = 0\nchanged = 0\nwhile len(hoge) - changed > int(K):\n  sum += hoge[changed]\n  changed += 1\n\nprint(sum)", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "from collections import Counter\na,b=map(int, input().split())\nc = Counter(list(map(int, input().split())))\ncnt = 0\nl = []\nm = []\n\nfor x,y in c.items():\n    l += [y]\n    m += [x]\n\nM = len(m)\nL = sorted(l)\nif M <= b:\n    print(0)\nif M > b:\n    for i in range(M-b):\n        cnt += L[i]\n    print(cnt)", "passed": true, "time": 0.38, "memory": 14216.0, "status": "done"}, {"code": "N,K = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\ndic={}\nfor i in A:\n    if i not in list(dic.keys()):\n        dic[i]=1\n    else:\n        dic[i]+=1\ndic=sorted(list(dic.items()),key=lambda x:x[1],reverse=True)\nk=0\nans=0\nfor key,value in dic:\n    if k>=K:\n        ans+=value\n    k+=1\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14184.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nnum_map = dict()\nfor i in range(n):\n    if a[i] not in num_map:\n        num_map[a[i]] = 1\n    else:\n        num_map[a[i]] += 1\n\nrest_key_num = max(0, len(num_map) - k)\nvalues = sorted(list(num_map.values()))\nres = 0\nfor j in range(rest_key_num):\n    res += values[j]\nprint(res)\n", "passed": true, "time": 0.15, "memory": 14264.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nA = list(map(int,input().split()))\nD = dict.fromkeys(range(1,n+1),0)\nans = 0\nfor a in A:\n  D[a] += 1\nD = sorted(D.items(), key=lambda x:x[1])\nfor i in range(n-k):\n  ans += D[i][1]\nprint(ans)", "passed": true, "time": 0.24, "memory": 14240.0, "status": "done"}, {"code": "import collections\nN ,K = map(int,input().split())\nlsA = list(map(int,input().split()))\ncounterA = collections.Counter(lsA)\nvalu = list(counterA.values())\nvalu.sort()\nkind = len(set(lsA))\nif kind <= K:\n    ans = 0\nelse:\n    ans = sum(valu[:kind - K])\nprint(ans)", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "N,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndic={}\nfor i in range(N+1):\n    dic[i]=0\nfor i in A:\n    dic[i]+=1\n\ndic_sort=sorted(dic.values(),reverse=True)\n\nprint(sum(dic_sort[K:]))", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "import collections as c\nn,k=map(int,input().split());a=c.Counter(map(int,input().split()))\nprint([0,sum(sorted([i for i in a.values()])[:len(a)-k])][len(a)>k])", "passed": true, "time": 0.14, "memory": 14036.0, "status": "done"}, {"code": "n,k=list(map(int, input().split()))\na_list=[int(i) for i in input().split()]\n\ndic={}\n\nfor i in a_list:\n    if i in dic:\n        dic[i]+=1\n    else:\n        dic[i]=1\n\ndic2=sorted(list(dic.items()), key=lambda x:x[1])\n\nans=0\n\nif len(dic)>k:\n    num=len(dic)-k\n    for i in range(num):\n        ans+=dic2[i][1]\n\n    \nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14328.0, "status": "done"}, {"code": "from collections import Counter\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nt=list(set(a))\nc=sorted(Counter(a).most_common(),key=lambda x:x[1])\nnum=len(t)-k\nif num<0:\n    print(0)\n    return\nelse:\n    ans=0\n    for i in range(num):\n        ans+=c[i][1]\n    print(ans)", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "from collections import Counter, deque, defaultdict\nn, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nt = defaultdict(int)\nfor x in A:\n    t[x]+=1\nB = []\nfor x in list(t.values()):\n    B.append(x)\nB.sort()\nif(len(B)<=k):\n    print((0))\n    return\n    \nans = 0\nfor i in range(0, len(B)):\n    ans+=B[i]\n    if len(B)-(i+1) <= k:\n        break\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nA = list(map(int,input().split()))\nL = [0] * n\nans = 0\n\nfor a in A:\n  L[a-1] += 1\nL = sorted(L)\nfor i in range(n-k):\n  ans += L[i]\n\nprint(ans)", "passed": true, "time": 0.24, "memory": 14272.0, "status": "done"}, {"code": "import sys\nfrom collections import Counter\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n    n, k = map(int, input().split())\n    a = list(map(int, input().split()))\n    a_cnt = sorted(list(Counter(a).values()))\n    s = set(a)\n    t = max(0, len(s) - k)\n    print(sum(a_cnt[0:t]))\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\n\nd={}\n\nfor x in range(n):\n  if a[x] not in d:\n    d[a[x]]=0\n  d[a[x]]+=1\n  \nans=0\nans1=[]\nfor g in d:\n  ans1.append(d[g])\n  \nif len(ans1)<=k:\n  print((0))\n  \nelse:\n  ans1.sort()\n  r=len(ans1)-k\n  for t in range(r):\n    ans+=ans1[t]\n    \n  print(ans)\n  \n", "passed": true, "time": 0.15, "memory": 14236.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_, k = map(int, input().split())\na = [int(i) for i in input().split()]\n\nc = C(a).values()\nd = len(c) - k\nif 0 < d:\n    print(sum(sorted(c)[:d]))\nelse:\n    print(0)", "passed": true, "time": 0.16, "memory": 14252.0, "status": "done"}, {"code": "#k = int(input())\n#s = input()\n#a, b = map(int, input().split())\n#s, t = map(str, input().split())\n#l = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n#a = [input() for _ in range(n)]\n\nn,k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nd = [0]*(n+1)\n\nfor i in range(n):\n    d[a[i]] += 1\n\nd.sort()\n\nprint((sum(d[:n-k+1])))\n", "passed": true, "time": 0.15, "memory": 14268.0, "status": "done"}, {"code": "import collections as c\nn,k = map(int,input().split())\nx = list(map(int,input().split()))\ny = c.Counter(x)\ns = []\nfor i in y.items():\n    s.append([i[1],i[0]])\ns.sort()\nans = 0\nfor i in range(len(s)-k):\n    ans += s[i][0]\nprint(ans)", "passed": true, "time": 0.15, "memory": 14236.0, "status": "done"}, {"code": "from collections import Counter\n_, K = map(int, input().split())\nA = list(map(int, input().split()))\n_, cnt = zip(*Counter(A).most_common()[::-1])\nprint(sum(cnt[:len(cnt) - K]))", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nfrom collections import Counter\nimport sys\nsys.setrecursionlimit(10**6)\n\n\nn, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nc = Counter(a)\n\nc = list(c.most_common())\n# c = c.most_common()\nlen_c = len(c)\n# print(len_c)\n# print(c)\nans = 0\nwhile(len_c-k > 0):\n    # print(len_c-k)\n    # print()\n    # print(k)\n    i, j = c.pop()\n    len_c -= 1\n    ans += j\nprint(ans)\n", "passed": true, "time": 0.31, "memory": 14228.0, "status": "done"}, {"code": "from collections import Counter\nn,k = map(int, input().split())\na = list(map(int, input().split()))\n\ncnt = Counter(a)\n\nl = len(cnt)\nt = l-k\nans = 0\nfor i in sorted(cnt.values()):\n  if t <= 0: break\n  t -= 1\n  ans += i\nprint(ans)", "passed": true, "time": 0.16, "memory": 14108.0, "status": "done"}, {"code": "N, K = list(map(int, input().split()))\nA = list(map(int,input().split()))\n\nB = [0]*N\nfor i in range(N):\n    B[A[i]-1]+=1\n\nB.sort()\n\nprint((sum(B[0:N-K])))\n", "passed": true, "time": 0.16, "memory": 14280.0, "status": "done"}, {"code": "from collections import Counter\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nl = Counter(a)\nif len(set(a)) <= k:\n    print(0)\nelse:\n    ci = list(l.values())\n    ci.sort()\n    i = 0\n    cnt = len(ci)\n    ans = 0\n    while cnt > k:\n        cnt -= 1\n        ans += ci[i]\n        i += 1\n    print(ans)", "passed": true, "time": 0.16, "memory": 14272.0, "status": "done"}, {"code": "from collections import Counter\n\nn, k = map(int, input().split())\na = [int(an) for an in input().split()]\nans = 0\nset_a = set(a)\nnum_of_types = len(set_a)\nif num_of_types > k:\n  cnt = Counter(a)\n  ans = sum(sorted(cnt.values())[: num_of_types - k])\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nfrom collections import Counter\ns = list(map(int,input().split()))\nnum = Counter(s)\nif len(num) <= k:\n    print(0)\nelse:\n    n = len(num) - k\n    a = 0\n    ans = 0\n    for i in sorted(num.values()):\n        if a == n:\n            break\n        \n        ans += i\n        a += 1\n        \n    print(ans)", "passed": true, "time": 0.15, "memory": 14112.0, "status": "done"}, {"code": "from collections import Counter\n_, K = map(int, input().split())\nA = sorted(list(Counter(input().split()).values()))\nprint(sum(A[:len(A)-K]))", "passed": true, "time": 0.24, "memory": 14036.0, "status": "done"}, {"code": "from collections import Counter, deque, defaultdict\nn, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nt = defaultdict(int)\nfor x in A:\n    t[x]+=1\nB = list(t.values())\nB.sort()\nif(len(B)<=k):\n    print((0))\n    return\n\nans = sum(B[:len(B)-k])\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14316.0, "status": "done"}, {"code": "import operator\nfrom collections import Counter\nn,k=[int(_) for _ in input().split()]\nD=Counter([int(_) for _ in input().split()])\nD=dict(sorted(list(D.items()), key=operator.itemgetter(1),reverse=True))\nc=0\ni=0\nfor _ in D:\n    if i>=k:\n        c+=D[_]\n    i+=1\nprint(c)\n", "passed": true, "time": 0.15, "memory": 14264.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\na.sort()\nb = [0]\nc = n\nd = 1\nfor i in range(n-1):\n    if a[i] == a[i + 1]:\n        d += 1\n        c -= 1\n    else:\n        b.append(d)\n        d = 1\nb.append(d)\nb.sort()\nfor i in range(len(b) - 1):\n    b[i+1] += b[i]\nprint((b[max(0, c-k)]))\n", "passed": true, "time": 0.15, "memory": 14420.0, "status": "done"}, {"code": "n,k = map(int, input().split())\na = list(map(int, input().split()))\nfrom collections import Counter\na1 = Counter(a).most_common()\nnum = 0\nif k < len(a1):\n    for i in range(1,len(a1)-k+1):\n        num += a1[-i][1]\n    print(num)\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "N, K = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\nX = [0] * N\n\nfor i in range(N):\n    X[A[i] - 1] += 1\n\nX = sorted(X, reverse=True)\n\nS = sum(X[:K])\n\nans = N - S\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14136.0, "status": "done"}, {"code": "_, k = map(int, input().split())\nd = {}\nfor i in map(int, input().split()):\n    if i in d:\n        d[i] += 1\n    else:\n        d[i] = 1\nd = sorted(d.values(), reverse=True)\nprint(sum(v for v in d[k:]))", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "import collections\nn,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nans=0\nc=collections.Counter(a)\nif len(c)<k:\n    print(ans)\n    return\nl=c.most_common()\nfor i in range(1,-k+len(c)+1):\n    ans+=l[-i][1]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "N,K=list(map(int,input().strip().split()))\nA=list(map(int,input().strip().split()))\n\nd={}\n\nfor n in range(N):\n    if d.get(A[n])==None:\n        d[A[n]]=1\n    else:\n        d[A[n]]+=1\n\ndn=sorted(list(d.items()),key=lambda x:x[1])\n\nif K>=len(d):\n    print((0))\nelse:\n    cnt=0\n    ans=0\n    for n in range(len(dn)):\n        ans+=dn[n][1]\n        cnt+=1\n        if cnt==len(d)-K:\n            break\n    print(ans)\n", "passed": true, "time": 0.22, "memory": 14092.0, "status": "done"}, {"code": "from collections import Counter\n\nn, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nCA = Counter(A)\n\nkouho = CA.most_common()[::-1]\nans = 0\nidx = 0\nwhile idx < len(CA) - k:\n    key, val = kouho[idx]\n    ans += val\n    idx += 1\nprint(ans)\n\n", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "N,K = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\nB = [0]*(N+1)\nfor i in range(N):\n    B[A[i]] += 1\nB.sort(reverse = True)\ncnt = 0\nfor i in range(K):\n     cnt += B[i]\nprint((N - cnt))\n", "passed": true, "time": 0.14, "memory": 14352.0, "status": "done"}, {"code": "N, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nA_dict = dict()\nfor i in range(N):\n    if A_dict.get(A[i]) is None:\n        A_dict[A[i]] = 1\n    else:\n        A_dict[A[i]] += 1\nA_dict_len = len(list(A_dict.keys()))\nans = 0\nA_dict_sorted = sorted(list(A_dict.items()), key=lambda a: a[1])\n#print(A_dict_sorted)\nfor i in range(max(0, A_dict_len - K)):\n    ans += A_dict_sorted[i][1]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14176.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 23 15:50:08 2020\n\n@author: liang\n\"\"\"\n\nN, K = map(int,input().split())\nd = [0]*N\nA = [int(x) for x in input().split()]\n\nfor a in A:\n    d[a-1] += 1\n    \nd.sort(reverse=True)\n\nans = N - sum(d[:K])\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14208.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n# N=O(10^5)\u306a\u306e\u3067\u3001O(N)\u3067\u89e3\u304f\n# ABC-155-C-Poll \u306e\u985e\u984c\n\n# \u5404\u6570\u5b57\u306e\u51fa\u73fe\u56de\u6570\u3092\u6570\u3048\u308b\ndic = {}\nfor i in range(N):\n  a = A[i]\n  if a not in dic: dic[a] = 1\n  else: dic[a] += 1\n\n# dic\u3092\u6607\u9806\u306b\u30bd\u30fc\u30c8\ndic = sorted(dic.items(), key=lambda x:x[1])\n\n# dic\u306f [(5, 1), (3, 2), (2, 2), (4, 2), (1, 3)] \u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\n# dic\u306evalue\u306b\u304a\u3044\u3066\u3001\u524d\u304b\u3089len(dic)-K\u500b\u306e\u548c\u3092\u53d6\u308b\nans = 0\nfor i in range(max(len(dic)-K, 0)):\n  ans += dic[i][1]\n  \nprint(ans)", "passed": true, "time": 0.14, "memory": 14184.0, "status": "done"}, {"code": "from collections import Counter\n\nn, k = map(int, input().split())\nA = list(map(int, input().split()))\n\ncnt_A = sorted(Counter(A).values())\n\nans = 0\nif len(cnt_A) <= k:\n    print(ans)\nelse:\n    for i in range(len(cnt_A) - k):\n        ans += cnt_A[i]\n    print(ans)", "passed": true, "time": 0.14, "memory": 14380.0, "status": "done"}, {"code": "from collections import Counter\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ncnt=Counter(A)\ncnt_sorted=sorted(cnt.items(), reverse=True,key=lambda x:x[1])\n\nsum=0\nfor i in range(min(K,len(cnt))):\n    sum+=cnt_sorted[i][1]\n\nprint(N-sum)", "passed": true, "time": 0.16, "memory": 14144.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ncount = {}\nfor val in A:\n    if val in count:\n        count[val] += 1\n    else:\n        count[val] = 1\n\nans = 0\ndiff = len(set(A)) - K\nif diff > 0:\n    count_sorted = sorted(count.items(), key=lambda x:x[1])\n    for k,v in count_sorted:\n        ans += v\n        diff -= 1\n        if diff == 0:\n            break\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "from collections import Counter\nn,k=map(int,input().split())\nL=Counter(list(map(int,input().split())))\nnum=max(len(L)-k,0)\nans=0\nif num==0:\n    print(0)\n    return\nL2=sorted(L.values())\nprint(sum(L2[:num]))", "passed": true, "time": 0.15, "memory": 14304.0, "status": "done"}, {"code": "import collections\nN,K=map(int,input().split())\nL=list(map(int,input().split()))\nL=sorted(L)\nc = collections.Counter(L)\nc=c.most_common()\nans=0\nif len(c)>K:\n  for i in range(len(c)-K):\n    ans+=c[len(c)-i-1][1]\n  print(ans)\nelse:\n  print(0)", "passed": true, "time": 0.15, "memory": 14140.0, "status": "done"}, {"code": "import collections\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\n\na_cnt = collections.Counter(a)\n#print(a_cnt)\na_sort = sorted(list(a_cnt.values()),reverse=True)\n#print(a_sort)\n#print(a_sort[k:])\nprint((sum(a_sort[k:])))\n", "passed": true, "time": 0.16, "memory": 14124.0, "status": "done"}, {"code": "from collections import Counter\n\ndef main():\n    N, K = map(int, input().split())\n    A = list(map(int, input().split()))\n\n    unchange = sum(tuple[1] for tuple in Counter(A).most_common(K))\n    print(N-unchange)\n\nmain()", "passed": true, "time": 0.26, "memory": 14196.0, "status": "done"}, {"code": "import collections\nN,K = list(map(int,input().split()))\nN_List = list(map(int,input().split()))\n\nChou_List = collections.Counter(N_List)\nif len(Chou_List) <= K:\n    print((0))\nelse:\n    Chou_List = sorted(list(Chou_List.values()),reverse=True)\n    print((sum(Chou_List[K:])))\n", "passed": true, "time": 0.23, "memory": 14244.0, "status": "done"}, {"code": "from collections import Counter as CC\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = CC(A)\nC = sorted(B.values())\nprint(sum(C[:max(0, len(C) - K)]))", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "import bisect as bs\nN, K = (int(x) for x in input().split())\nA = sorted([int(x) for x in input().split()])\nf = lambda X, x: bs.bisect_right(X,x)-bs.bisect_left(X,x)\ncnt = sorted([f(A,a) for a in set(A)],reverse=True)\nvrt = len(cnt)\nprint(sum(cnt[K:]) if vrt > K else 0)", "passed": true, "time": 0.28, "memory": 14084.0, "status": "done"}, {"code": "from collections import Counter\n\nn, K = map(int, input().split())\na = list(map(int, input().split()))\nc = Counter()\nfor x in a:\n  c[x] += 1\n\ncv = [(k, x) for x, k in c.items()]\ncv.sort(reverse=True)\n\nans = 0\nwhile len(cv) > K:\n  k,_ = cv.pop()\n  ans += k\nprint(ans)", "passed": true, "time": 0.15, "memory": 14052.0, "status": "done"}, {"code": "N, K = map(int, input().split())\na_list = list(map(int, input().split()))\n\nnum_dic = {}\nfor a in a_list:\n  count = num_dic.get(a, 0)\n  num_dic[a] = count + 1\n\nreplace_num = len(num_dic.keys()) - K\nreplace_num = 0 if replace_num < 0 else replace_num\nans = 0\nfor i, taple in enumerate(sorted(num_dic.items(), key = lambda x:x[1])):\n  if i == replace_num:\n    break\n  ans += taple[1]\n\nprint(ans)", "passed": true, "time": 0.24, "memory": 14144.0, "status": "done"}, {"code": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nimport collections\nc = collections.Counter(a)\nli = []\nans = 0\nfor v,num in  c.items():\n    li.append((v,num))\nll = sorted(li,key=lambda x: x[1],reverse=True)\n\nfor i in range(k,len(ll)):\n    #print(ll[i][1])\n    ans += ll[i][1]\n\nprint(ans)", "passed": true, "time": 0.23, "memory": 14116.0, "status": "done"}, {"code": "N,K = map(int,input().split())\nA = list(map(int,input().split()))\nimport collections\na = collections.Counter(A)\nb = a.most_common()\nans = 0\nif len(b) > K:\n    for i in range(K,len(b)):\n        ans += b[i][1]\nprint(ans)", "passed": true, "time": 0.22, "memory": 14216.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nB = [0] * (N + 1)\nfor i in range(N):\n    B[A[i]] += 1\nB.sort(reverse=True)\ncnt = 0\n# \u5229\u7528\u53ef\u80fd\u306a\u7a2e\u985e\u6570\u304cK\u500b\u306a\u306e\u3067N-K\u3067\u7b54\u3048\u306b\u306a\u308b\nfor i in range(K):\n    cnt += B[i]\nprint(N - cnt)", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "from collections import Counter\n\nn, k = list(map(int, input().split()))\na = Counter(list(map(int, input().split())))\na = list(a.items())\na.sort(key=lambda x: x[1])\nopt = len(a) - k\nans = 0\nif opt > 0:\n    for i in range(opt):\n        ans += a[i][1]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14064.0, "status": "done"}, {"code": "from collections import Counter\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nL = Counter(A)\n\nans = N\nfor a, cnt in L.most_common(K):\n  ans -= cnt\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "import collections\nn,k=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\ncount=0\nb=len(collections.Counter(a))\nc=collections.Counter(a).most_common()\n#print(b)\nfor i in range(min(k,b)):\n    count+=c[i][1]\n#    print(count)\nans=len(a)-count\nprint(ans)", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "n,k = map(int, input().split())\na = list(map(int, input().split()))\nfrom collections import Counter\na1 = Counter(a).most_common()\nnum = 0\nif k < len(a1):\n    for i in range(1,len(a1)-k+1):\n        num += a1[-i][1]\n    print(num)\nelse:\n    print(0)", "passed": true, "time": 0.15, "memory": 14176.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\nimport collections\nN, K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nC=collections.Counter(A)\nKEY=list(C.keys())\ncount=0\nif len(KEY)>K:\n    D=len(KEY)-K\n    L=C.most_common()[::-1]\n    for ii in range(D):\n        count+=L[ii][1]\n\nprint(count)\n    \n", "passed": true, "time": 0.14, "memory": 14280.0, "status": "done"}, {"code": "n, k= list(map(int, input().split()))\na = list(map(int, input().split()))\nimport collections\n\na = collections.Counter(a)\nkey = list(a.values())\n#print(key)\nkey.sort()\n#print(key)\nans = sum(key[:len(key)-k])\nprint(ans)\n", "passed": true, "time": 0.25, "memory": 14288.0, "status": "done"}, {"code": "N,K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nm= [0 for i in range(200001) ]\nfor i in range(N):\n  m[A[i]] += 1\nm.sort(reverse=True)\nans = 0\nfor i in range(K,N):\n  if ( m[i] == 0 ):  break\n  ans += m[i]\nprint(ans)\n", "passed": true, "time": 0.16, "memory": 15072.0, "status": "done"}, {"code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nb = [0]*n\nfor i in range(n):\n    b[a[i]-1] += 1\nc = [i for i in b if i != 0]\nc.sort()\nif len(c) - k > 0:\n    print(sum((c[0:len(c)-k])))\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nA_dic = {}\nA_count = []\n\nfor i in range(N):\n  if A[i] not in A_dic.keys():\n    A_dic[A[i]] = 1\n  else:\n    A_dic[A[i]] += 1\n    \nfor i in A_dic.keys():\n  A_count.append(A_dic[i])\n  \nif len(A_count) <= K:\n  print(0)\nelse:\n  ans = 0\n  A_count.sort()\n  for i in range(len(A_count) - K):\n    ans += A_count[i]\n  else:\n    print(ans)", "passed": true, "time": 0.23, "memory": 14132.0, "status": "done"}, {"code": "# cook your dish here\nimport operator\nN,K=map(int,input().split())\nlst=list(map(int,input().split()))\nx=[]\nx=set(lst)\nif len(x)<=K:\n    print(0)\nelse:\n    freq={}\n    for i in lst:\n        if i in freq:\n            freq[i]+=1\n        else:\n            freq[i]=1\n    # l=[]\n    # l=list(freq.items())\n    s={}\n    s = dict(sorted(freq.items(), key=operator.itemgetter(1)))\n    # print(s)\n    # l.sort()\n    cc=abs(len(x)-K)\n    # print(cc)\n    v=0\n    for key,value in s.items():\n        \n        v+=s[key]\n        # print(key)\n        cc-=1\n        if cc==0:\n            print(v)\n            break", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "N,K = map(int,input().split()) \nA = list(map(int,input().split()))\nA.sort()\ntemp = 1\nV = [] \nfor i in range(N-1):\n    if A[i] == A[i+1]:\n        temp+=1 \n    else:\n        V.append(temp)\n        temp = 1\n\nV.append(temp)\nV.sort() \nans = N- sum(V[-K:])\nprint(ans)", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "from collections import Counter\n \nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n \n# N=O(10^5)\u306a\u306e\u3067\u3001O(N)\u3067\u89e3\u304f\n# ABC-155-C-Poll \u306e\u985e\u984c\n# \u65b9\u91dd\uff1a\u5404\u6570\u5b57\u306e\u51fa\u73fe\u56de\u6570\u3092\u6570\u3048\u308b\n \n# Counter(\u30ea\u30b9\u30c8) \u306f\u8f9e\u66f8\u578b\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3042\u308a\u3001\u30ad\u30fc\u306b\u8981\u7d20\u30fb\u5024\u306b\u51fa\u73fe\u56de\u6570\u3068\u3044\u3046\u5f62\u5f0f\n# Counter(\u30ea\u30b9\u30c8).most_common() \u306f(\u8981\u7d20, \u51fa\u73fe\u56de\u6570)\u3068\u3044\u3046\u30bf\u30d7\u30eb\u3092\u51fa\u73fe\u56de\u6570\u9806\u306b\u4e26\u3079\u305f\u30ea\u30b9\u30c8\nA = Counter(A).most_common()\n \n# \u51fa\u73fe\u56de\u6570\u306e\u5927\u304d\u3044\u65b9\u304b\u3089K\u7a2e\u985e\u306f\u305d\u306e\u307e\u307e\u306b\u3057\u3066\u304a\u304f\u3002\u3053\u308c\u306b\u3088\u3063\u3066\u3001\u5909\u3048\u306a\u3044\u500b\u6570\u304c\u6c42\u307e\u308b\u3002\n# \u5909\u3048\u308b\u500b\u6570\u306f\u3001N-(\u5909\u3048\u306a\u3044\u500b\u6570)\ns = 0\nfor i in range(min(K, len(A))):\n  s += A[i][1]\n  \nprint(N-s)", "passed": true, "time": 0.14, "memory": 14040.0, "status": "done"}, {"code": "N,K=map(int,input().split())\nA=list(map(int,input().split()))\na=[0]*200000\nb=[]\nfor i in A:a[i-1]+=1\nfor i in a:\n    if i:b.append(i)\nb.sort()\nans=0\nfor i in range(len(b)-K):ans+=b[i]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14952.0, "status": "done"}, {"code": "from collections import deque\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nnums = [0]*N\n\nfor i in range(N):\n  nums[A[i]-1] += 1\n\nnums.sort()\n\nnums = deque(nums)\n\nwhile True:\n  if nums[0] == 0:\n    nums.popleft()\n  else:\n    break\nnums = list(nums)\nif len(nums) <= K:\n  print(0)\nelse:\n  print(sum(nums[:len(nums)-K]))", "passed": true, "time": 0.14, "memory": 14060.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\na=[int(i) for i in input().split()]\nc=[0]*(n+1)\nfor i in a:\n    c[i]+=1\nprint((sum(sorted(c)[:-k])))\n", "passed": true, "time": 0.24, "memory": 14012.0, "status": "done"}, {"code": "def main():\n    n, k = map(int, input().split())\n    inlis = list(map(int, input().split()))\n    indic = dict()\n    cnt = 0\n    for i in range(n):\n        num = inlis[i]\n        if num in indic:\n            indic[num] += 1\n        else:\n            indic[num] = 1\n            cnt += 1\n    if cnt <= k:\n        print(0)\n    else:\n        indic_sort = sorted(indic.items(), key=lambda x:x[1])\n        #print(indic_sort)\n        sa = cnt - k\n        tmp = 0\n        ans = 0\n        for j in range(n):\n            tmp += 1\n            ans += indic_sort[j][1]\n            if tmp == sa:\n                break\n        print(ans)\n\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.24, "memory": 14252.0, "status": "done"}, {"code": "n,k=[int(i) for i in input().split()]\na=[int(i) for i in input().split()]\n\na.sort()\n\ntimes=[0]*(n+1)\nfor i in a:\n    times[i]+=1\ntimes.sort()\n\n\nfor i in range(n+1):\n    if times[i]!=0:\n        j=i\n        break\n\nans=0\nif len(times)>k-j:\n    for i in range(j,len(times)-k):\n        ans+=times[i]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = [0 for i in range(N+1)]\n \nfor a in A:\n  B[a] += 1\nnums = [b for b in B if b > 0]\nnums.sort()\nn = len(nums)\nif n <= K:\n  print(0)\nelse:\n  print(sum(nums[:n-K]))", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "from collections import Counter\n\nN, K = list(map(int, input().split()))\nA = Counter(list(map(int, input().split())))\n\nif(len(A) > K):\n    values, counts = list(zip(*A.most_common()[-(len(A)-K):]))\n    print((sum(counts)))\nelse:\n    print((0))\n", "passed": true, "time": 0.15, "memory": 14148.0, "status": "done"}, {"code": "#\n# abc081 c\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"5 2\n1 1 2 2 5\"\"\"\n        output = \"\"\"1\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"4 4\n1 1 2 2\"\"\"\n        output = \"\"\"0\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_3(self):\n        input = \"\"\"10 3\n5 1 3 2 4 1 1 2 3 4\"\"\"\n        output = \"\"\"3\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N, K = list(map(int, input().split()))\n    a = list(map(int, input().split()))\n    an = [0] * N\n    for i in a:\n        an[i-1] += 1\n    an.sort(reverse=True)\n    ans = 0\n    for i in an:\n        if K == 0:\n            ans += i\n        else:\n            K -= 1\n    print(ans)\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14396.0, "status": "done"}, {"code": "N,K = map(int, input().split())\na_list = list(map(int, input().split()))\ncounter_list = [0]*N\nfor i in a_list:\n    counter_list[i-1] += 1\n\ncounter_list.sort(reverse=True)\n\nans = N - sum(counter_list[:K])    \n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14156.0, "status": "done"}, {"code": "N,K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nX=[0 for _ in range(N+1)]\nfor a in A:\n    X[a]+=1\nX.sort(reverse=True)\nprint((N-sum(X[0:K])))\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "from collections import Counter\n\n\ndef mapt(fn, *args):\n    return tuple(map(fn, *args))\n\n\ndef Input():\n    return mapt(int, input().split(\" \"))\n\n\ndef main():\n    n, k = Input()\n    a = sorted(Counter(Input()).items(), key=lambda x:x[1], reverse=True)\n    temp = 0\n    for i in range(min(k, len(a))):\n        temp += a[i][1]\n    print(sum(i for _, i in a) - temp)\n\n\nmain()", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "def main():\n\tN, K = map(int, input().split())\n\tA = list(map(int, input().split()))\n\n\tlst = {}\n\n\tfor num in A:\n\t\tif num in lst:\n\t\t\tlst[num] += 1\n\t\telse:\n\t\t\tlst[num] = 1\n\n\tlst_sorted = sorted(lst.items(), key = lambda x: x[1])\n\n\tlen_lst_sorted = len(lst_sorted)\n\n\tif len_lst_sorted <= K:\n\t\tprint(0)\n\t\treturn\n\telse:\n\t\tans = 0\n\t\tfor i in range(len_lst_sorted - K):\n\t\t\tans += lst_sorted[i][1]\n\t\tprint(ans)\n\t\treturn\n\n  \ndef __starting_point():\n  \tmain()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14356.0, "status": "done"}, {"code": "import collections\nN,K=map(int,input().split())\na=list(map(int,input().split()))\nc=collections.Counter(a)\nl=len(c)\nc=list(c.items())\nc.sort(key=lambda x: x[1])\nans=0\nfor i in c:\n  if l<=K:\n    break\n  ans+=i[1]\n  l-=1\nprint(ans)", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "n,k= map(int,input().split())\nXl = list(map(int,input().split()))\nfrom collections import Counter\nXdic = Counter(Xl)\nvaluelist = sorted(list(Xdic.values()), reverse=True)\nprint(sum(valuelist[k:]))", "passed": true, "time": 0.14, "memory": 14072.0, "status": "done"}]