Let λ 1 (n) denote the least invariant factor in the invariant factor decomposition of the multiplicative group M n = (Z/nZ) × . We give an asymptotic formula, with order of magnitude x/ √ log x, for the counting function of those integers n for which λ 1 (n) = 2. We also give an asymptotic formula, for any even q ≥ 4, for the counting function of those integers n for which λ 1 (n) = q. These results require a version of the Selberg-Delange method whose dependence on certain parameters is made explicit, which we provide in an appendix. As an application, we give an asymptotic formula for the counting function of those integers n all of whose prime factors lie in an arbitrary fixed set of reduced residue classes, with implicit constants uniform over all moduli and sets of residue classes.