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.
from collections import Counter
N, K = map(int, input().split())
A = Counter(input().split())
print(A)

print(sum(sorted(A.values(), reverse=True)[K:]))
from collections import Counter
N, K = map(int, input().split())
A = Counter(input().split())

print(sum(sorted(A.values(), reverse=True)[K:]))