AFTER spending much of her political capital fighting corruption, Dilma Rousseff, Brazil's president, has had to pick her battles. Seven senators from her resentful coalition have already quit, and more warn they may follow. Ms Rousseff has put most of her legislative plans on hold until relations improve. But she is training her remaining firepower on what may be Brazil's biggest public-policy problem: a voracious pension system that threatens to bust the budget and damage the economy.

On February 29th the lower house of Congress approved a reform of civil servants' pensions. It would cap the defined-benefit plans of future federal-government employees at 3,916 reais ($2,150) a month, the same level as private-sector workers. Those who want more would have to contribute to a separate fund. That would make the system less unfair and, in the long term, a bit cheaper. The bill still must pass the Senate and Ms Rousseff's powers of persuasion may not prove sufficient. Even if it is approved, however, it would only be a first step towards fixing a system that Fabio Giambiagi, an economist at the National Development Bank, calls “absolutely the most generous in the world. The economy of Brazil is very different from Greece's. But in terms of retirement rules, we are worse.” Uniquely among large economies, Brazil is a young country with the pensions bill of an old one (see chart). It has just ten over-65s for every hundred 15- to 64-year-olds, fewer than anywhere in the G7. And yet it spends 13% of GDP on pensions, more than any G7 member except Italy, where the share of old people is three times higher than in Brazil. In fact, so few Brazilians pay for pensions, and so many get them, that the country has 35 pensioners for every 100 contributing workers, a higher ratio than in the United States. Brazil's pensions are among the world's most generous, too, replacing 75% of average income. Some of this is welfare spending intended to cut poverty. Rural workers aged over 60, and anyone poor and over 65, can get a pension of 622 reais—the minimum wage—without ever having paid into the system. But this only costs around 2% of GDP a year. The real culprits are rules that let contributing workers retire earlier, on bigger pensions, than anywhere else.

To retire on full pay most Brazilians need only contribute for 15 years and keep going until 65 for men and 60 for women. But after 35 years paying in, a man of any age can retire on a smaller, though still generous, pension. A woman must pay in for just 30 years. All pensions must exceed the minimum wage, which has trebled in real terms since 1995. As a result, most Brazilians retire startlingly early: at 54 on average for a man in the private sector, and just 52 for a woman. Survivors' benefits have no age limits. Families inherit pensions in their entirety, meaning young, childless widows never need work. A tenth of all 45-year-olds are already receiving a pension.

In a young country, a pay-as-you-go system should yield surpluses, which can be invested in infrastructure and education. But Brazil's is already in deficit. Investment is only about 20% of GDP, and just 2.9% of GDP comes from the government.

Children get particularly slim pickings after pensions are paid. Taking income levels and differing demographies into account, Brazil spent twice as lavishly on each pensioner as the OECD average, but only two-thirds as generously on the education of each child. The only handout a poor child can hope for is the Bolsa Família, a grant averaging 115 reais per family per month. If he were over 65 his family would receive over five times as much. As a result, very few old people are below the poverty line, but a third of children are.

The price for such distorted priorities is already high. But soon it will be unpayable. Payroll taxes for pensions are already greater in Brazil, at 32% of gross salary, than in all G7 countries except Italy. According to Bernardo Queiroz of the Federal University of Minas Gerais, without reforms, by 2050 they would have to reach a crushing 86% to keep the system going.

Averting such a disaster will take big changes: more people contributing, less generous pensions and a ban on early retirement. Rerunning his calculations, Mr Queiroz found that, together, these would cause the pensions payroll tax in 2050 to rise to 40% (still a daunting figure). But such reforms are not even being discussed. “It's a puzzle,” he says. “The unions are against changes. But without them, the workers they represent are paying for other people to get much more generous pensions than they will ever get themselves.”

Brazil will have to face reality sooner or later. But the risk is that it will take an economic crisis to goad the government into action. Big reforms were pushed through in 1999, when the country was struggling to pay its foreign debts. (Incredibly, pensions used to be even more generous, with no cap in the private sector and retirement on full pay at any age after 35 years in work.)

Mr Queiroz says the lesson from abroad is that once those in or near retirement are very numerous, reform becomes so urgent that it will have to hit them too. At that point, they will mobilise and block all changes, even to the brink of collapse. An unaffordable system can only be fixed while the share of old people is small. Brazil's chance to change is brief, he says—perhaps ten years.