For Western countries, 2016 is shaping up to be the year of immigration. The Republican presidential candidates Donald Trump and Ted Cruz want to build a wall between the United States and Mexico. British Prime Minister David Cameron wants, as a precondition for the country’s continued membership in the European Union, to be granted an “emergency brake” on benefits payments to European immigrants to the United Kingdom. And throughout Europe, from Greece to Germany, debate is fierce over how many refugees from the Middle East, South Asia, and North Africa can be accommodated—and at what cost.

Cost, of course, is the biggie. Although the world’s inexorable movement toward a global labor market might be a good thing overall, helping increase wealth and better match skills with positions, it’s unclear what this means for the modern welfare state. The idea that a state should look after its citizens’ economic and social well-being—providing safety nets in the form of unemployment insurance, pensions, or health insurance—has spread widely since its first big trial run in 19th-century Europe. After all, it’s now on display in various forms from the Americas to Russia to Saudi Arabia to China. But can it survive in an age with fewer borders? Won’t state coffers eventually be empty if more and more immigrants start drawing on them?

The surprising answer is: not necessarily. What’s more, some of the countries most concerned about these questions at the moment are the ones most likely to profit from greater immigration.

“Immigrants come in and they work and pay taxes and they contribute,” said George Borjas, an economics professor at Harvard’s Kennedy School of Government. “At the same time, some of them get sick, some of them have children who have to go to school, and all kinds of programs kick in in order to provide them services. And the question at the end is which of these two money streams is greater. There’s been a lot of work on that,” he said, and the studies are generally open to interpretation.

In the case of “congestible public goods”—as in a road or transit system or education system where you might need to expand capabilities to avoid traffic jams—more immigrants means more expenditures, according to Tim Krieger, an economics professor at Freiburg University. “And the immigrants don’t pay that much in taxes” due to lower average incomes, he said. “They do pay value-added taxes and sales taxes, of course, but hardly any income taxes and capital taxes and so on.”

But, Krieger added, one of the big caveats here is the effect that immigrants have on pension or retirement systems, which constitute a huge chunk of the public budget in many countries. Pension systems are typically pay-as-you-go programs, which means everyone currently working gets taxed and that money immediately goes to current retirees. Immigrants tend to have a tremendously positive impact on the pension system, he said. In fact, their arrival triggers what “pension economists usually call an ‘introductory gift.’ If you find a job, you start paying contributions and all these contributions—because it’s a pay-as-you-go system—go directly to the retirees.” That can swiftly shore up government finances in countries with an aging population, which describes most of Europe. Plus, “There’s been research showing that even if the people are net beneficiaries of the pension system [i.e. if, by the time these immigrants grow old, the state has committed to larger pension payouts], even then it would have a positive effect on pay-as-you-go simply because they will have children who become contributors, and immigrants tend to have more children than natives.” In Germany, said Krieger, that kind of effect on the pension system “is a factor of three or four compared to all the other benefits.”

With less predictable benefits like unemployment insurance and health care, a lot depends on the specific country and the demographics of those immigrating.

In the United States, said Borjas, “The most recent credible work dates way back to the 1997 National Academy report, which depending on how you do things finds whatever you want [it to find].” (Borjas sat on the expert panel that put the study together.) “The number that was widely cited is that the typical immigrant arriving in would create over the long haul an $80,000-plus benefit. But the problem with that number was that it looked over the next 300 years,” Borjas continued, and long-term estimates are of little use when you consider how much depends, for example, on fluctuations in the host country’s labor market. “We can barely predict next year,” he pointed out. When the panel tried to predict what would happen in, say, 1998 if the country were to accept 460,000 “new immigrant-headed households,” it found instead a $10 increase in the fiscal burden on native households—in other words, a negative effect from immigration.

Those numbers are old, and Borjas is currently part of a new panel tasked with publishing an updated report later this year. What is certain, however, is that “skilled immigrants are clearly much more beneficial in terms of the welfare state. Skilled immigrants earn more, which means they pay more taxes, and they are in much less need of services. The more unskilled the immigrant, the more likely the immigrant will be a fiscal burden. It’s the same thing in terms of a native.”

In European welfare states, the same principle holds. And there, some of the short-term numbers are more promising than in the United States. Consider the United Kingdom, for example: Right now, David Cameron is trying to wrangle a deal with the European Union stating, essentially, that the British government can halt benefits payments to EU migrants, most likely from poorer Eastern European countries, if it experiences a large influx.

Judging by the research, that’s bordering on bonkers. Not only, as Borjas noted, is it “very hard to prove” that immigrants move places specifically in response to welfare incentives, but, as Krieger pointed out, recent studies suggest the U.K. has benefited disproportionately from immigration, including immigration from Eastern Europe.

A 2014 study by Christian Dustmann at University College London and Tommaso Frattini at the University of Milan found that, between 1995 and 2011, immigrants from the European Economic Area had a more positive impact on the U.K.’s state finances than natives did. On average, they brought with them a higher degree of educational attainment than the average U.K.-born worker, and that gap has actually widened over time. The government benefits doubly, attracting highly educated, higher-earning workers whose education it did not pay for. In other words, it saves money. The fact that these immigrants tend to be young, and “far from reaching their full economic potential,” means that even if they receive more government benefits as they age, “the contributions of those who decide to stay in the UK will probably increase through individual career development.” In that regard, they’ll have a better effect on the country’s fiscal situation than aging Britons: The study also found that immigrants’ wages, for each additional year worked, grew faster than natives’, quickly increasing the tax revenue immigrants generated. The authors pointed out that these findings are consistent with a 2013 review by the Organization for Economic Cooperation and Development, which found that the U.K. benefits fiscally from immigration far more than, say, Scandinavian countries do.

There’s some evidence that the same conclusion applies to Germany. Holger Bonin of the Center for European Economic Research, for example, has estimated that, in 2012, “among immigrants, the value of paid taxes and contributions exceeded the average value of transfers [government services such as health insurance and unemployment benefits] by 3,300 Euros per head.”

Of course, when you’re comparing how much countries profit or lose from immigration, a lot comes down to how you measure.

“The Bonin study led to an interesting debate in Germany,” said Krieger, because another economist, Hans-Werner Sinn, said Bonin had failed to account for the cost of public goods like transit systems and education. Sinn argued that including these expenses would result in an overall negative fiscal effect for each immigrant. “However,” said Krieger, “[Sinn] simply divided all public spending and interest payments on public debt by the total population, consisting of both immigrants and natives. Other scholars believe, however, that this is not the correct way to do it,” since the cost of including each extra person in a system that already exists, and would exist with or without immigration, is probably less than what simply dividing total expenditure by total population would suggest. “Using Bonin’s data and an alternative breakdown of public spending,” Krieger continued, “would still lead to a surplus of 200 euros.”

There’s substantial evidence that the arrival of refugees from outside Europe will be less beneficial than the influx of skilled immigrants from within Europe. The 2014 U.K. study, for example, showed non-European immigrants lagging behind European immigrants in terms of net contributions. “We know that EU immigrants are on average better educated than non-EU citizens and that high-skilled immigrants have a strong positive fiscal impact, which is not the case for low-skilled immigrants,” said Krieger. On top of that, refugees need food and shelter upon arrival, and often lack immigration papers, among other things. Even so, during some years examined in the U.K. study, non-European immigrants still beat out natives in terms of net contributions.

All these studies suggest that, humanitarian and social-policy concerns aside, certain types of economies are well-positioned to turn immigration flows into profit. Bonin argued, for example, that Germany has benefitted from immigration more than some of its neighbors primarily because of three factors: first, Germany’s labor-hungry economy; second, the relatively high level of integration immigrants achieve in German society; and third, Germany’s relatively large pension system (which means immigrants’ pension contributions are disproportionately valuable). Countries that urgently need workers and pension contributions, therefore, might receive a boost even from lower-skilled immigrants—especially if governments invest in the education and integration of new arrivals. Bonin, for instance, based his estimate for the profitability of immigration in Germany in part on the assumption that at least 30 percent of immigrant children wind up performing, in terms of their career trajectory, on par with native German children. For that, you need them to acquire language skills quickly, integrate to a certain extent with the local population, and experience a certain degree of upward mobility.

In a world where the refugee crisis has made immigration not just an economic issue but a moral one, this question of integration might just be the most important of them all. “If all you care about is making the welfare state more self-sustaining, more profitable, a skilled immigration is really quite good at that,” said Borjas. But with a large influx of both skilled and unskilled workers, calculating the likelihood of immigrants having a net positive impact involves more than assessing unemployment levels and the overall condition of the host economy. It also requires considering potential negative “externalities,” which are very hard to measure economically. What if the migrants pose national-security concerns, or come into conflict with the native population? What if their short-term competition with young natives for jobs outweighs, in the public’s mind, their contribution to the elderly’s pension checks?

That’s what makes the current refugee crisis so complicated and agonizing. David Cameron may be contradicting good research in proposing his “emergency brake” for Eastern European migrants, but, at least at a basic level (and once you’ve stripped away the hysteria and racism), European leaders worried about an inflow of non-European refugees aren’t. Although there may be a fiscal or economic case for admitting a Syrian refugee—the German Institute for Economic Research recently offered one in a report claiming that the benefits of the huge migration would outweigh the costs in Germany in three to 10 years—it’s a very hard case to make in most countries, particularly in the short term.

The stronger case is the moral one, but it’s a tough sell to voters facing short-term hardships. The honest thing for a humanitarian-minded politician to say would be, “This is going to be painful. But it’s the right thing to do. And if we play our cards right, we could reap the benefits in 15 years.” It’s a message few politicians have hazarded to deliver.