According to Investopedia, opportunity cost refers to a benefit that a person could have received, but gave up, to take another course of action. We often hear of the opportunity costs of things like cable subscriptions, gym memberships, and buying a latte every day, but what about the opportunity cost of having children?

What if you’re on the fence about having a second or third child, or any children at all for that matter? I’m on the fence myself (full disclaimer: I’m leaning heavily towards the no kids camp), so I decided to run the numbers. People rarely anticipate the full cost of having children. And although I don’t believe this should stop someone having a child if they want to be a parent, opportunity cost should probably be part of the decision making process for anyone is on undecided about having children.

So let’s do a thought experiment. I took the average annual costs of a single child in a middle class family directly from this recent USDA study and assumed that instead of spending that money to take care of a child, someone invested that amount in low cost index funds with an average annual return of 8% (an amount that is just under the average S&P 500 return including years with market crashes). After 18 years of contributions and returns, this non-parent would have $661,009 (in 2015 dollars) which is more than double the often stated “price tag” of having a child if you simply added the yearly costs without factoring in how much return you missed out on.

Confused about investing? Start Here.

Let’s go a step further. The average age a parent at the first of their first child in the US is 25 years old, so let’s assume that’s when this non-parent begins investing the amount they aren’t spending on a child. Like we just mentioned, their account would have $661,009 after 18 years assuming an average annual return of 8%. If this is a retirement account, this non-parent probably won’t touch that money until they are age 65. So how much would they find in their account when they’re 65? A lot. Over $4.1 million to be exact.

And that’s in 2015 dollars. If you have a baby in 2018 and raise them until they are age 18 in 2036, you’ll be paying more per year due to inflation. Let’s use the 2.2% inflation rate mentioned in the study.

The 2015 total cost of raising a child (not including the opportunity cost of lost returns) is $298,220, but when a baby born in 2018 is 18 years old in 2036, the parents would have paid $463,507 thanks to inflation. If we factor in those 8% returns, the non-parent’s account would total $1,027,371 in 2036, 18 years after they began contributing. And when they open that account at retirement, they’re looking at a sweet sum of $6,467,581.

See More: 7 Simple Financial Guidelines That Will Save You TONS of Money

A few things to mention. Child costs do not include the cost of college, life insurance premiums for children or parents, or any lost wages a parent might suffer due to having children. Factoring these in would make the final totals even larger.

I calculated this using a return each year of 8% (slightly under the market’s average annual return). As you probably know, past performance does not guarantee future performance, so the actual opportunity cost could be a bit larger or smaller depending on how the markets behave during the years you are raising your child. And I assumed the costs/contributions were spread out evenly throughout the year instead of dropping a lump sum in at the beginning or end of the year.

Also, I calculated the opportunity cost for a single child. According to the USDA, since children share certain costs, the costs for two siblings won’t be exactly 2x what a single child would cost. Their calculations for multiple children depend on the age difference between the children. You can read about the estimated expenditures for multiple children in the full USDA report.

Money Saving Tips