Counting combinations with restrictions