def 解():

    iN,iK = [int(_) for _ in input().split()]

    #aA = [int(_) for _ in input().split()]

    dA = {}

    def addD(d,a):

        if a in d:

            d[a] += 1

        else:

            d[a] = 1

    for a in [int(_) for _ in input().split()]:

        addD(dA,a)

    aList = sorted(list(dA.items()),key=lambda x:x[1])

    print((sum([x[1] for x in aList[0:len(aList)-iK]])))

解()

def 解():

    iN,iK = [int(_) for _ in input().split()]

    aA = [0]*(iN+1)

    for a in [int(_) for _ in input().split()]:

        aA[a] += 1

    print((sum(sorted(aA)[0:iN-iK+1])))

解()

def 解():
    iN, iK = [int(_) for _ in input().split()]
    # aA = [int(_) for _ in input().split()]
    dA = {}

    def addD(d, a):
        if a in d:
            d[a] += 1
        else:
            d[a] = 1

    for a in [int(_) for _ in input().split()]:
        addD(dA, a)
    aList = sorted(list(dA.items()), key=lambda x: x[1])
    print((sum([x[1] for x in aList[0 : len(aList) - iK]])))


解()

def 解():
    iN, iK = [int(_) for _ in input().split()]
    aA = [0] * (iN + 1)
    for a in [int(_) for _ in input().split()]:
        aA[a] += 1
    print((sum(sorted(aA)[0 : iN - iK + 1])))


解()

-    # aA = [int(_) for _ in input().split()] -    dA = {} - -    def addD(d, a): -        if a in d: -            d[a] += 1 -        else: -            d[a] = 1 - +    aA = [0] * (iN + 1) -        addD(dA, a) -    aList = sorted(list(dA.items()), key=lambda x: x[1]) -    print((sum([x[1] for x in aList[0 : len(aList) - iK]]))) +        aA[a] += 1 +    print((sum(sorted(aA)[0 : iN - iK + 1])))