Until now, design of the annual influenza vaccine has relied on phylogenetic or whole-sequence comparisons of the viral coat proteins hemagglutinin and neuraminidase, with vaccine effectiveness assumed to correlate monotonically to the vaccine-influenza sequence difference. We use a theory from statistical mechanics to quantify the non-monotonic immune response that results from antigenic drift in the epitopes of the hemagglutinin and neuraminidase proteins. The results explain the ineffectiveness of the 2003-2004 influenza vaccine in the United States and provide an accurate measure by which to optimize the effectiveness of future annual influenza vaccines.