If we have to use math, I'd say: the headaches are temporal - the effect of all the good you've done today is effectively gone tomorrow one way or another. But killing a person means, to quote "Unforgiven", that "you take away everything he's got and everything he's ever gonna have". So the calculation needs at least a temporal discount factor.
I also believe that the examples are too contrived to be actually useful. Comparing a room with one person to another with five million is like comparing the fine for a person traveling at twice the speed limit with that of someone traveling at 10% the speed of light - the results of such an analysis are entertaining to think about, but not actually useful.
Thus, when comparing headaches to a man being tortured, there's no clear reason to suppose that there is a number of headaches that is worse than the torture.
(Intuitively, it's hard to say saving 100 people is 100x as good as saving 1, because we can't have 100 best friends, but it doesn't affect the math at all)
It's pretty short, I liked it. Was surprised to find myself agreeing with it at the end of my first read.
* He slides between talking about personal decisions vs decisions about someone else. The argument for Headache is couched in terms of whether an average person would drive to the chemist. Whilst the argument for shifting from Headache to Many Headaches is couched in terms of decisions made by an external party. This feels problematic to me. There may be some workaround.
* He describes rejecting transitivity as being overwhelmingly implausible. Is that obvious? Ethical considerations ultimately boil down to subjective evaluations, and there seems no obvious reason why those evaluations would be transitive.