update inversion counter