An exact multiplicity result for a class of semilinear equations