Ted stumbles on the formula for a perfect marriage: happiness in direct proportion to sex vs shopping.