modify count_inversion