Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
S=list(S)
B=[]

def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)

for _ in S:
  a=A[0]
  j = bisect_right(A,a)
  B+=[j]
  del A[:j]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))

Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
import sys
input = sys.stdin.readline

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
S=list(S)
B=[]

def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)

for i in S:
  a=A[0]
  j = bisect_right(A,a)
  B+=[j]
  del A[:j]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
S=list(S)
B=[]

def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)

for i in S:
  a=A[0]
  j = bisect_right(A,a)
  B+=[j]
  del A[:j]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
S=list(S)
B=[]

def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)

for i in S:
  a=A[0]
  j = bisect_right(A,a)
  B+=[j]
  del A[:j]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
S=list(S)
B=[]

def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)

for i in S:
  a=A[0]
  j = bisect_right(A,a)
  B.append(j)
  del A[:j]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
S=list(S)
B=[]

def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)

for i in S:
  a=A[0]
  j = bisect_right(A,a)
  B.append(j)
  A=A[j:]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
B=[]
for i in S:
  a=A[0]
  b=len(A)
  for k in range(b):
    if A[k]!=a:
      j=k
      break
  else:
    j=b
  B.append(j)
  A=A[j:]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
B=[]
for i in S:
  j=0
  while A[j]==A[0]:
    j+=1
    if j==len(A):
      break
  B.append(j)
  A=A[j:]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
S=set(A)
B=[]
for i in S:
  k=A.count(i)
  B.append(k)
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))

Fixed submission:
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)