n,k=list(map(int,input().split()))

a=list(map(int,input().split()))



a.sort()



s=[]

ai=a[0]

acnt=-1

for i in range(n):

    if a[i]>ai:

        s.append([acnt+1,ai])

        acnt=0

        ai=a[i]

    else:

        acnt=acnt+1

s.append([acnt+1,ai])

        



if len(s)<=k:

    print((0))

else:

    s.sort()

#    print(s)

    ssum=0

    for i in range(len(s)-k):

        ssum=ssum+s[i][0]

    print(ssum)    

    
n,k=list(map(int,input().split()))

a=list(map(int,input().split()))



c=[0]*(n+1)

for i in range(n):

    c[a[i]]+=1

c.sort(reverse=True)

csum=0

for i in range(k):

    csum+=c[i]

print((n-csum))
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
s = []
ai = a[0]
acnt = -1
for i in range(n):
    if a[i] > ai:
        s.append([acnt + 1, ai])
        acnt = 0
        ai = a[i]
    else:
        acnt = acnt + 1
s.append([acnt + 1, ai])
if len(s) <= k:
    print((0))
else:
    s.sort()
    #    print(s)
    ssum = 0
    for i in range(len(s) - k):
        ssum = ssum + s[i][0]
    print(ssum)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
    c[a[i]] += 1
c.sort(reverse=True)
csum = 0
for i in range(k):
    csum += c[i]
print((n - csum))

-a.sort() -s = [] -ai = a[0] -acnt = -1 +c = [0] * (n + 1) -    if a[i] > ai: -        s.append([acnt + 1, ai]) -        acnt = 0 -        ai = a[i] -    else: -        acnt = acnt + 1 -s.append([acnt + 1, ai]) -if len(s) <= k: -    print((0)) -else: -    s.sort() -    #    print(s) -    ssum = 0 -    for i in range(len(s) - k): -        ssum = ssum + s[i][0] -    print(ssum) +    c[a[i]] += 1 +c.sort(reverse=True) +csum = 0 +for i in range(k): +    csum += c[i] +print((n - csum))