You might think amassing a multimillion-dollar portfolio on a modest salary of $40,000 requires winning the lottery. But if you consistently live below your means and maximize your retirement savings benefits, you can reach retirement age with about $4 million. It's just a matter of time and compound interest.

Meet Adam

Adam is 24 years old and a recent graduate who just landed his first "real" job that pays $40,000 per year, offers free health insurance, and a 401(k) match of $0.50 per dollar up to 6% of his salary. He lives well below his means.

Adam has roommates, cooks most of his meals at home, drives a sensible car he paid for in cash, and doesn't have much of a shopping habit. He'll occasionally splurge on a night out with friends or a fancy dinner with his girlfriend, but he keeps an eye on his budget. His cost of living is about $2,000 per month, or $24,000 per year.

Keeping his expenses low will allow Adam to save a good chunk of his income and maximize his retirement benefits.

A person writing in a notebook while counting pennies from a piggybank.

Image source: Getty Images.

How much can Adam save?

In order to figure out how much Adam can save each year, we need to do a bit of tax planning. He has to pay 7.65% in FICA taxes on his salary, which takes out $3,060 each year from the $40,000 he earns. Then he spends $24,000 on living expenses, so that leaves $12,940 split between income taxes and his savings.

Figuring out income tax is a bit trickier. Adam lives in Missouri, a state with median income tax rates, where the top income tax bracket is 5.4%. 

The more Adam saves in a pre-tax retirement account like an IRA or 401(k), the lower his tax liability will be. Additionally, saving in a pre-tax retirement account will lower his adjusted gross income to the point where he becomes eligible for the saver's credit.

Adam finds that if he saves exactly $11,577 in pre-tax retirement accounts, he'll max out the saver's credit and owe just $1,363 per year in state and federal income tax. He decides to max out his IRA with $6,000 and contribute $5,577 to his 401(k) at work. That also earns him the full employer match of $1,200, bringing his total savings to $12,777 per year.

How to turn $12,777 into $3 million

If Adam saves $12,777 per year every year until he turns 66 (42 years total) and invests that money in a simple index fund, he'll end up with a portfolio worth nearly $4 million (assuming an 8% annual rate of return).

Keep in mind this calculation doesn't factor in cost-of-living adjustments to Adam's salary, but it also uses a relatively high estimate for potential investment growth. In reality, Adam will likely contribute more every year as he gets raises, but his average returns may be lower, effectively balancing things out.

It will take a lot for Adam to maintain such a low cost of living as he gets older. He may ditch the roommates for a spouse, but the spouse might contribute an income too. He might have kids, who are generally very expensive and don't contribute to household income. Life changes in ways we don't expect, so even the best savings plan will need flexibility.

Does Adam need $4 million?

The good news is there's no reason for Adam to amass $4 million in savings while living on just $24,000 per year. Using the 4% rule for retirement and the same level of living expenses, Adam could enjoy the same lifestyle on a nest egg of just $600,000.

If Adam saves aggressively while he's young and in his 20s, he can take his foot off the pedal, spend more on himself, and still retire quite comfortably.

Saving $12,777 per year for six years and then letting that compound until age 66 still results in a nest egg of about $1.5 million, and the 4% rule on a $1.5 million portfolio would mean $60,000 in annual income. His living expenses could rise substantially from current levels, and that's still more than enough money for Adam to retire comfortably, even after paying taxes on his retirement account distributions.

The key lesson you should take away from Adam's story? If you focus on saving as much as possible when you're young and maximize those savings through your various accounts, you'll have a much easier time reaching a multimillion-dollar portfolio by the time you retire.