When your paycheck hits and you pay your bills, it’s easy to spend the rest of your cash on dinner out with friends, vacation or a new pair of shoes. But investing your money now can make a huge difference over time — and make dreams like buying a home and retiring comfortably a reality.

The benefits of investing vary depending on your age, salary, market conditions and more. But our return on investment calculator shows that investing just $100 per month for 30 years and assuming a rate of return of 7 percent would leave you with a portfolio of nearly $98,000, even taking into account taxes and inflation. When you consider that the historical average annual return of the S&P 500 is around 10 percent, you can see how real a possibility it is to build wealth over time when you invest consistently.

But wrapping your head around how much you should invest each month while still having enough to pay for essentials and fun can be more difficult. Financial advisors say the trick is to make sure you have enough cash for the short-term, and plan around your goals and risk tolerance.

Cover the basics

Before you start investing, there are two important steps to take: make sure you have a fully funded emergency fund and pay off high-interest debt.

Financial advisors typically recommend building up a fund that can cover three to six months of expenses to keep you afloat if the unexpected hits, like you lose your job or are hit with a surprise medical bill. You want this money easily accessible, like in a high-yield savings account. Be sure to think about your situation specifically —  if you own a second home or have children, your emergency fund likely needs to be larger than a single person or a recent college graduate living with their parents.

Then, look at your debt obligations. Debt varies based on how toxic it is, says Brian Matthews, a financial advisor and head of investment strategy at Domain Money. While you can likely comfortably pay off a mortgage, student loans and auto loans while also investing, you should focus on paying down high-interest debt like a credit card balance before you start or increase your investing.

But when it comes to investing, there are no hard and fast rules that apply to everyone. For example, someone who has an employer match through their 401(k) will likely want to contribute enough to at least get that free money while also continuing to build their emergency fund, Matthews says.

Outline your goals

A key part of any financial strategy is identifying what you want your money to do for you, and that goes for when choosing how much to invest. For many people, retirement is the ultimate goal. But there are likely other objectives you’re saving for, like a child’s college tuition, a downpayment, vacation or a wedding.

If your goal or upcoming expense is less than five years out, you probably want to look at stashing that money in a conservative vehicle like a high-yield savings account, says Dan Perrino, principal wealth manager at Savvy Advisors.

“We don’t want to be forced to sell stocks in a down market,” Perrino says.

But it’s also important to have an honest conversation with yourself about risk tolerance, he adds: How will you react if your portfolio is down 25 percent in a year? If you think you’ll panic and sell, you may want to consider increasing allocation to more conservative investments like bonds, especially if you’re nearing retirement.

Calculate how much you can set aside

Because all financial planning starts with thinking about your goals, calculate how much you need to regularly save to hit those milestones. Advisors will typically collect information like your current age, when you want to retire and how much you expect your retirement lifestyle to cost, then factor in variables like inflation to help determine how much you can set aside.

There are plenty of free calculators you can use to plan for yourself, including Bankrate’s retirement calculator. To maintain your same standard of living in retirement, Matthews says these calculations often come out to saving around 15-20 percent of your income at least, including contributions to an employer-sponsored retirement plan like a 401(k).

Of course, that’s not possible for everyone, especially younger investors just starting out their careers. Matthews recommends setting aside what you can to start — ideally at least 10% — then upping that figure throughout your career. If you’re considering how much to invest outside of a retirement account that gets contributions directly from your paycheck, you can also work backwards: Take your paycheck, minus your bills and any savings for short-term goals, and invest the rest.

If you’re already investing every month, use an online calculator to determine whether you need to increase those contributions to meet your goals. Perhaps that means making adjustments elsewhere in your spending.

“Budgeting is kind of like your blood flow,” Matthews says. “It’s the main methodology in which you can accomplish all your goals.”

Bottom line

Investing consistently each month can help you reach your financial goals, whether it’s retirement, buying a home, or funding other life milestones. Start by building an emergency fund and paying off high-interest debt first to lay a strong financial foundation, and then consider your risk tolerance, short-term objectives, and long-term goals. This will help you when deciding how much to invest monthly. Remember that even starting with a small percentage of your income and gradually increasing your investments can lead to building significant wealth over time.