# ABC081C - Not so Diverse (ARC086C)

from collections import Counter





def main():

    N, K, *A = list(map(int, open(0).read().split()))

    C = list(Counter(A).values())

    C.sort(reverse=1)

    ans = sum(C[K:])

    print(ans)





if __name__ == "__main__":

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

from collections import Counter





def main():

    N, K, *A = open(0).read().split()

    C, K = list(Counter(A).values()), int(K)

    C.sort(reverse=1)

    ans = sum(C[K:])

    print(ans)





if __name__ == "__main__":

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


def main():
    N, K, *A = list(map(int, open(0).read().split()))
    C = list(Counter(A).values())
    C.sort(reverse=1)
    ans = sum(C[K:])
    print(ans)


if __name__ == "__main__":
    main()

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


def main():
    N, K, *A = open(0).read().split()
    C, K = list(Counter(A).values()), int(K)
    C.sort(reverse=1)
    ans = sum(C[K:])
    print(ans)


if __name__ == "__main__":
    main()

-    N, K, *A = list(map(int, open(0).read().split())) -    C = list(Counter(A).values()) +    N, K, *A = open(0).read().split() +    C, K = list(Counter(A).values()), int(K)