the solution of the CountDistinctSlices