(NEXSTAR) – It’s a problem most homeowners deal with every year: How much candy do you need to buy for Halloween?

You don’t want to buy too much and then end up having to eat or throw away an excessive amount of fun-size Hershey bars and Kit Kats. And you definitely don’t want to be the house that runs out early and has to tell the 5-year-old girl dressed as Elsa that you just gave away the last of your candy and that she gets nothing.

Luckily, your days of deciding how many bags of fun-size treats to buy are over thanks to a new trick-or-treat calculator from Omni Calculator.

The tool gives users a rough estimate of how many bags of candy they need to buy depending on several factors. The first is a guess at how many trick-or-treaters you’re expecting to get at your house this year.

If you haven’t been counting each year you pass out candy, here’s a good way to guess. According to Instacart, 61% of people handing out treats this year are expecting 25 or more trick-or-treaters, while 29% are expecting 50 or more. Unless you live in an extremely busy neighborhood, this is a realistic assumption.

The next factor is determining how decorated your house is. The more festive, the more candy trick-or-treaters are probably expecting. For now, we’ll assume your home is normally decorated, meaning you’ll hand out about three pieces of candy per kid.

Next is determining what the weather will be. Obviously, the nicer the night, the more kids will stop by. According to the National Weather Service, it looks like there may be a chance of rain in parts of the Midwest and Texas during the week of Oct. 31 to Nov. 6. While the rest of the country should avoid a rainy Halloween.

(Photo Courtesy: National Weather Service)

And finally, you’ll need to know how much candy is in the bag you are looking to buy. The size of the bag can vary from store to store and also depends on the brand of candy you’re buying. We’ll go with a bigger bag that comes with 75 pieces of fun-size candy bars.

With all this factored in, the calculator says that if you’re expecting 25-50 trick-or-treaters, buying two bags of candy should get the job done.

If you’d like to try the trick-or-treater calculator yourself, you can go to the Omni Calculator site.