A Quantitative Model of Counterfactual Reasoning