Alternately, and not too difficult, is to run the odometer routine twice: each time, as as a Slater determinant is calculated, compute \( M \), but do not store the Slater determinants except the current one. You can then count up the number of Slater determinants with a chosen \( M \). Then allocated storage for the Slater determinants, and run the odometer algorithm again, this time storing Slater determinants with the desired \( M \) (this can be done with a simple logical flag).