Solution for CountFactors