Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
seta=set(a)

mylist=[a.count(i) for i in seta]
mylist.sort(reverse=True)

#print(mylist)
val=sum(mylist[:k])
  
print(n-val)


Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
seta=set(a)
lenseta=len(seta)

mylist=[a.count(i) for i in seta]
mylist.sort(reverse=True)

#print(mylist)
val=sum(mylist[:k])
  
print(n-val)

Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(n,k,a)

mylist=[0 for i in range(n)]
for i in range(n):
  mylist[i]=a.count(i)
mylist.sort(reverse=True)

val=sum(mylist[:k])
  
print(n-val)

Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(n,k,a)

mylist=[0 for i in range(n)]
for i in range(n):
  mylist[i]=a.count(i)
mylist.sort(reverse=True)

val=0
for i in range(0,k):
  val+=mylist[i]
  
print(n-val)

Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(n,k,a)

mylist=[]
for i in range(n):
  mylist.append(a.count(i))
mylist.sort(reverse=True)

val=0
for i in range(0,k):
  val+=mylist[i]
  
print(n-val)

Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(n,k,a)
mydict={}
mylist=[]
for i in a:
    if i not in mydict:
        mydict[i]=a.count(i)
z=len(mydict)-k

for i in mydict.values():
  mylist.append(i)

#print(mydict)
if z<=0:
    print(0)
else:
    ans=0
    for i in range(z):
        tmp=min(mylist)
        ans+=tmp
        mylist.remove(tmp)
    print(ans)



Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(n,k,a)
mydict={}
mylist=[]
for i in a:
    if i not in mydict:
        mydict[i]=a.count(i)
z=len(mydict)-k

for i in mydict.values():
  mylist.append(i)

#print(mydict)
if z<=0:
    print(0)
else:
    ans=0
    for i in range(z):
        tmp=min(mylist)
        ans+=tmp
        mylist.remove(tmp)
    print(ans)



Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(n,k,a)
mydict={}
mylist=[]
for i in a:
    if i not in mydict:
        mydict[i]=a.count(i)

for i in mydict.values():
  mylist.append(i)
mylist.sort()      
z=len(mydict)-k
#print(mydict)
if z==0:
    print(0)
else:

    ans=0
    for i in range(z):
        ans+=mylist[i]
    print(ans)

Fixed submission:
import collections

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

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)