Heap, counting,  and flag