Counting number of inversions added