ids = [1,1,1,2,3,2,5,5];
m = 2
def deleteProducts(items, m):
from collections import OrderedDict
result = sorted(items, key = items.count, reverse = True)
result = result[:len(result)-m]
res = [(el, result.count(el)) for el in result]
return len(list(OrderedDict(res).items()))
deleteProducts(ids,m)