If you are struggling to save money and pay off debt, the 50-20-30 rule can help you budget in accordance with your financial goals, according to Rob Berger, founder of The Dough Roller. He says the simple rule provides flexibility, whether you want to pay off debt, save, invest or all three.

The rule splits your after-tax, take-home pay into three buckets.

“Fifty percent is for needs, thirty percent is for wants, twenty percent is for savings,” Berger tells NBC News BETTER.

Here’s the breakdown.

50 percent: Includes rent/mortgage, food, bills, minimum debt payments and other essentials

20 percent: Includes financial goals such as savings, investment, etc

30 percent: Dining, entertainment, etc

Figure out how much you can realistically save

Before you begin, you’ll need to determine out how much you can realistically save, says Berger.

For example, someone with high expenses and high debt may need to adjust the rule to 80-10-10 until they have reduced their debt and grown their savings.

But before you assume you can’t afford to save 20 percent, Berger advises, take the time to examine your spending habits.

“Rather than immediately say, ‘Oh, this won’t work, I can’t save 20 percent — which I understand, I’ve been there, most people have been there — spend some time thinking ‘Well, wait a minute, if I had to make this work, what choices could I make to make it work?’ Think through all the things you absolutely must have,” advises Berger.

“You got to focus on what you absolutely have to have, and that means really shrinking that 30 percent bucket — getting rid of everything you don’t have to have,” says Berger. “Which is not always easy and not always fun, but if you find yourself in a difficult financial situation, you’ve got to make those tough decisions.”

What can you cut out?

You might be overspending money in ways you don’t realize, says Berger. First, look at your major expenses — rent, mortgage, car payments, etc. — and ask yourself if there are ways to reduce them, he says. You might be able to save by moving to a cheaper city, for instance, or by purchasing a used car instead of a new one, he says.

If it’s not possible to cut back on major expenses, then you need to take a look at your smaller expenses, says Berger.

Go through the list of expenses in your 50 percent bucket and ask yourself: “Do I need this? Can I get rid of it, or can I somehow lower it?”

“If you haven’t checked car insurance rates in three years [for example] maybe you should shop around for better car insurance,” says Berger.

You’ll also need to examine the expenses in your 30 percent bucket to see what you tend to waste money on the most, he says. For some people, that may be clothes, for others, electronics or eating out. Berger suggest creating a mini-budget that will prevent you from overspending on your lifestyle habits. For instance, if you tend to splurge on dining out, create a dining budget that aligns with your savings goals.

“So you don’t have to track every dime if you don’t want to, just pick those one or two or three categories that cause you the most problems and set a budget that you don’t surpass for those categories,” says Berger.

He says there are plenty of online tools like YNAB that can help you manage your spending.

Figure out your savings goals

How you manage your 20 percent savings bucket will depend on your personal goals, says Berger.

If you don’t already have much saved, he suggests using it to build an emergency savings fund. Once you’ve got an amount you feel comfortable with, he says, you can start contributing part of your savings to an investment like an IRA or a mutual fund.

If your goal is to pay off debt, he says, you can start designating a percentage of your 20 percent bucket to pay above the minimum on your loans until they are paid off.

If debt isn’t an issue for you, he says, you can contribute part or all of the 20 percent to a retirement fund. But in most cases, Berger warns, investing 20 percent won’t be enough if you want to retire early.

“I would say you’re probably looking at at least 30 percent or higher and, again, it depends on how quickly you want to retire,” he says.

This financial calculator can help you figure out how much you’ll need to invest to retire early.

Control your wants and live beneath your means

Berger says the biggest challenge for most people using the 50-30-20 rule is controlling their wants and living beneath their means. He says this may especially be a struggle for young professionals getting a job for the first time.

“You’re getting the job with a little bit of money and you want as nice a car as you can afford, and you want as nice an apartment as you can afford, and then you sit back and you say ‘Oh, I can’t save 20 percent, that’s impossible.’ And it’s not impossible, it’s just that choices have been made that put you in a box that makes it really difficult,” he says.

Berger knows from experience. After graduating from law school in the 1990s, Berger was tens of thousands of dollars in debt. On top of that, he struggled with mortgage, car payments and other monthly expenses that piled up.

Through careful budgeting, he says his debts were paid off by 2016. He says the main reason he and his wife are now debt-free is because they continued to live beneath their means even as they paid off their loans.

“We live in the same house that we lived in — we bought it 14 years ago, it’s the same house we lived in when we made a lot less money,” he says.

Berger says they also contributed their savings to an investment account as they paid off their debt, which grew their nest egg.

“So we kept our lifestyle the same even while our income went up and we put all of that to pay down that debt… in saving and investing,” he says.

Berger’s advice to those who want to be debt free is simple: make a promise to yourself to not get into more debt.

“And to me the biggest struggle is just making that decision not to get into any more debt for any reason and sticking to it,” Berger says.

GET MORE SAVING AND SPENDING HACKS

Want more tips like these? NBC News BETTER is obsessed with finding easier, healthier and smarter ways to live. Sign up for our newsletter and follow us on Facebook, Twitter and Instagram.