A straightforward argument is presented to calculate the number of different major histocompatibility complex (MHC) molecules in an individual that maximizes the probability of mounting immune responses against a large number of foreign peptides. It is assumed that increasing the number of MHC molecules per individual, n, has three different effects: (i) it increases the number of foreign peptides that can be presented; (ii) it increases the number of different T-cell receptors (TCRs) positively selected in the thymus; but (iii) it reduces the number of TCRs by negative selection. The mathematical analysis shows that n = 1/f maximizes the number of different TCRs that pass through positive and negative selection and that n = 2/f maximizes the probability to mount immune responses against a large fraction of foreign peptides. Here f is the fraction of TCRs deleted by one MHC molecule. Both results depend on approximations that are discussed in the paper. The model presented has implications for our understanding of the evolutionary forces acting on the MHC.