Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    exit
else:
    count=[0]*len(As)
    for i in range(len(As)):
        count[i]=int(A.count(As[i]))
    num=sorted(count)
    num2=num[0:sa]
    ans=0
    for i in num2:
        ans+=i
    print(ans)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    exit
else:
    count=[0]*len(As)
    for i in range(len(As)):
        count[i]=A.count(As[i])
    num=sorted(count)
    ans=0
    for i in range(sa):
        ans+=num[i]
    print(ans)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    exit
else:
    count=[0]*len(As)
    for i in As:
        count[i]=A.count(i)
    num=sorted(count)
    ans=0
    for i in range(sa):
        ans+=num[i]
    print(ans)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    exit
else:
    count=[]
    for i in As:
        count.append(A.count(i))
    num=sorted(count)
    ans=0
    for i in range(sa):
        ans+=num[i]
    print(ans)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    break
else:
    count=[]
    for i in As:
        count.append(A.count(i))
    num=sorted(count)
    ans=0
    for i in range(sa):
        ans+=num[i]
    print(ans)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=len(As)-K
count=[]
for i in As:
    count.append(A.count(i))
num=sorted(count)
ans=0
for i in range(sa):
    ans+=num[i]
print(ans)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)