PP/2: complete mid_by_counting