fork download
  1. from collections import Counter
  2. import sys
  3.  
  4. def main():
  5. input = sys.stdin.read().split()
  6. N = int(input[0])
  7. K = int(input[1])
  8. A = list(map(int, input[2:2+N]))
  9.  
  10. counts = Counter(A)
  11. freq = sorted(counts.values(), reverse=True)
  12.  
  13. if len(freq) <= K:
  14. print(0)
  15. else:
  16. print(sum(freq[K:]))
  17.  
  18. if __name__ == "__main__":
  19. main()
Success #stdin #stdout 0.01s 7388KB
stdin
5 2
1 1 2 2 5
stdout
1