How to calculate how much to stock up on in your pantry.