The Number of Parties As a Function of Heterogeneity and Electoral System