Merge sort and count