inversion count works