# ARC086C - Not so Diverse (ABC081C)

from collections import Counter





def main():

    _, k, *a = list(map(int, open(0).read().split()))

    print((sum(sorted(list(Counter(a).values()), reverse=True)[k:])))





if __name__ == "__main__":

    main()
# ABC081C - Not so Diverse (ARC086C)

from collections import Counter





def main():

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

    A = sorted(list(Counter(input().split()).values()), reverse=True)

    print((sum(A[k:])))





if __name__ == "__main__":

    main()
# ARC086C - Not so Diverse (ABC081C)
from collections import Counter


def main():
    _, k, *a = list(map(int, open(0).read().split()))
    print((sum(sorted(list(Counter(a).values()), reverse=True)[k:])))


if __name__ == "__main__":
    main()

# ABC081C - Not so Diverse (ARC086C)
from collections import Counter


def main():
    n, k = list(map(int, input().rstrip().split()))
    A = sorted(list(Counter(input().split()).values()), reverse=True)
    print((sum(A[k:])))


if __name__ == "__main__":
    main()

-# ARC086C - Not so Diverse (ABC081C) +# ABC081C - Not so Diverse (ARC086C) -    _, k, *a = list(map(int, open(0).read().split())) -    print((sum(sorted(list(Counter(a).values()), reverse=True)[k:]))) +    n, k = list(map(int, input().rstrip().split())) +    A = sorted(list(Counter(input().split()).values()), reverse=True) +    print((sum(A[k:])))