  We quantify a recent theorem of Wiles on class numbers of imaginary quadratic
fields by proving an estimate for the number of negative fundamental
discriminants down to -X whose class numbers are indivisible by a given prime
and whose imaginary quadratic fields satisfy any given set of local conditions.
This estimate matches the best results in the direction of the Cohen-Lenstra
heuristics for the number of imaginary quadratic fields with class number
indivisible by a given prime. This general result is applied to study rank 0
twists of certain elliptic curves.
