Counts number of Inversions