Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.  He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.  Find the minimum number of balls that Takahashi needs to rewrite the integers on them.



def main()->None:
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    if len(A) > K:
        set_A = set(A)
        count = []
        for s_a in set_A:
            card = A.count(s_a)
            count.append(card)
        sorted_count = sorted(count)
        print(sorted_count)
        reduce_num = len(count) - K
        print(reduce_num)
        sum_count = 0
        counter = 0
        for c in sorted_count:
            if counter == reduce_num :
                break
            sum_count += c
            counter += 1

        print(sum_count)
    else:
        print(0)

if __name__ == "__main__":
    main()
from collections import Counter


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

if __name__ == "__main__":
    main()