Vaccination is an effective way to prevent an epidemic. It results in immunity for the vaccinated individuals, but it also reduces the infection pressure for unvaccinated people. Thus people may actually escape infection without being vaccinated: the so-called "herd effect." We analytically study the relation between the herd effect and the vaccination fraction for the seminal SIR compartmental model, which consists of a set of differential equations describing the time course of an epidemic. We prove that the herd effect is in general convex-concave in the vaccination fraction and give precise conditions on the epidemic for the convex part to arise. We derive the significant consequences of these structural insights for allocating a limited vaccine stockpile to multiple non-interacting populations. We identify for each population a unique vaccination fraction that is most efficient per dose of vaccine: our dose-optimal coverage. We characterize the solution of the vaccine allocation problem and we show the crucial importance of the dose-optimal coverage. A single dose of vaccine may be a drop in the ocean, but multiple doses together can save a population. To benefit from this, policy makers should select a subset of populations to which the vaccines are allocated. Focusing on a limited number of populations can make a significant difference, whereas allocating equally to all populations would be substantially less effective.