The first law of cosmochemistry