Fossil fuel companies stand to miss out on $9 trillion to $12 trillion in profits by the end of the century if carbon emissions are taxed at a high enough level to meet international climate goals. Cry us a river, right?

That’s because demand for coal, oil, and natural gas would fall as prices are pushed higher, leading companies to leave vast volumes in the ground, according to a new study.

On the flip side, how much revenue would be generated through taxes or the sale of carbon allowances? The study, published in the journal Climatic Change, found the fossil fuels that are mined and burned would generate carbon-tax or carbon-auction revenues of $21 trillion to $32 trillion during the same period. That means a net economic benefit of as much as $20 trillion.

“Implementing ambitious climate targets would certainly scale down fossil fuel consumption, so with reduced demand their prices would drop,” said Nico Bauer, lead author of the study and a scientist at the Potsdam Institute for Climate Impact Research. “The resulting profit loss would be overcompensated by revenues from auctioning emissions permits or taxing CO2.”

After crunching numbers with an energy-economy-climate model, Bauer said the researchers were surprised that “revenues from emissions pricing were found to be at least twice as high [as] the profit losses we estimate for the owners of fossil fuels.”

Although revenues from carbon pricing would exceed lost fossil fuel profits globally, the same would not be true in all countries. From the paper:

[R]egions with high energy demand like China would generate huge carbon rents that are much larger than the loss of fossil fuel rent. For other regions including the Middle East and North Africa showing the largest loss of fossil fuel rent the carbon rent is still sufficient to compensate. However, for a country like Russia the compensation is not feasible based on the domestically generated carbon rent.

The report authors point out that governments who levy carbon fees and taxes will get to decide how to spend the revenues. They could be funneled into green-energy projects and climate adaptation efforts, for example, or simply used to reduce income taxes.

“We know that fossil fuel owners will lose out on profits, but the big question is who will benefit from the new revenues generated by climate policy?” said coauthor Elmar Kriegler, also of the Potsdam Institute. “It will fall to policy makers and society at large to decide this.”