America’s retirement crisis could cost federal and state governments an estimated $1.3 trillion by 2040, according to a new analysis.

Inadequate retirement savings will result in higher public assistance costs, decreased tax revenue, lower household spending and a decline in standards of living, according to a report done for the Pew Charitable Trusts.

The anticipated costs —  $964 billion for the federal government and $334 billion for states between 2021 and 2040 — are “relatively shocking,” John Scott, director of Pew’s retirement savings project, said during a presentation on Thursday.

The shortfall is being driven in part by demographics, with the share of households including someone 65 or older that has less than $75,000 in annual income —  a level the report said indicated financial vulnerability — expected to jump 43% to 33 million by 2040.

The report found that minor increases in savings habits by those “vulnerable” households could alleviate the anticipated strain to federal and state budgets. Saving an extra $140 a month, or about $1,685 annually, over 30 years, the retirement savings gap and additional taxpayer burden could be eliminated, according to the analysis.

The research assumed an inflation-adjusted return of 5% on assets that shifted from a more aggressive to a more conservative portfolio over three decades.

The study pointed to the growth of state-sponsored automated retirement savings accounts, which have been adopted in 12 states, as a way to help as many as 56 million private-sector employees without employer-sponsored retirement savings plans. Such auto-IRA programs usually automatically enroll employees, who can then opt out.

Unlike many retirement savings programs at large private companies, auto-IRAs are Roth accounts, funded with a small percentage of a worker's after-tax paycheck. Users aren't able to lower their taxable income by contributing to retirement savings on a pre-tax basis, as workers can in 401(k) plans, and there are no matching contributions from employers.

This article was provided by Bloomberg News.