Getting regular exercise may help you save big on annual healthcare costs, especially if you’re living with cardiovascular disease. In a new study, heart patients who got at least 30 minutes of exercise five days a week spent about $2,500 less over the course of a year on drugs and medical bills than those who didn’t reach this recommended amount.

People without heart problems benefited from cost savings, as well. Even in the healthiest group surveyed—those with no cardiovascular disease and, at most, one risk factor for it—people who got regular exercise shelled out, on average, $500 less on annual medical costs.

The study, published last week in the Journal of the American Heart Association, looked at more than 26,000 responses from a 2012 national survey on health and exercise. Researchers divided these responses into two groups: people who had been diagnosed with cardiovascular disease—for which physical inactivity is a known risk factor—and those who had not. In this case, the researchers defined cardiovascular disease as coronary artery disease, stroke, heart failure, irregular heart beat, or peripheral artery disease.

For those without cardiovascular disease, they further divided them into three sub-groups based on how many risk factors they had. These risk factors included high blood pressure, high cholesterol, diabetes, smoking, and obesity.

Then they looked at exercise totals. Specifically, they wanted to know how much moderate and vigorous activity people were getting every week. Moderate activity was defined as anything that causes a light sweat or only modest increases in breathing or heart rate, and includes brisk walking, lawn mowing, or heavy cleaning. Vigorous activity includes running or race walking, lap swimming, or aerobics.

More than two-thirds of people with cardiovascular disease, and more than half of those without it, did not meet the recommended 30-minutes-a-day, 5-day-a-week minimum for moderate-to-vigorous activity.

That’s disappointing, say the study authors—especially because, when they crunched the numbers, they found that those who did exercise spent a lot less on health care compared to non-exercisers with otherwise similar health statuses.

When they factored out differences in age, sex, income, ethnicity, geographic region, and type of insurance, they found that people with cardiovascular disease who didn’t exercise regularly spent an average of $12,650 a year, compared with $10,092 for those who did.

People without cardiovascular disease spent much less in health care costs overall, especially those who had the fewest risk factors. But exercise still benefited their wallets, as well. Non-exercisers in the healthiest sub-group (one or no risk factors), for example, spent an average of $3,734 a year, compared to $3,240 for exercisers—a nearly $500 difference.

Those in the least healthy non-cardiovascular disease sub-group (with three or more risk factors) spent about $1,060 more when they didn’t exercise—including about $400 more on medications alone.

It’s well known that regular exercise reduces the risk of heart disease and other chronic health conditions, but these findings “also emphasize the favorable impact on how much you pay for health care,” said senior author Khurram Nasir, M.D., director of the Center for Healthcare Advancement & Outcomes and the High Risk Cardiovascular Disease Clinic at Baptist Health South Florida in Coral Gables, in a press release.

The average individual cost savings associated with exercise, when all study participants were grouped together, was about $700. The study also suggests that if just 20 percent more people with cardiovascular disease started to meet this exercise goal, the United States could save billions of dollars a year in health-care costs.

Since this was an observational study, the researchers could not draw a definitive cause-and-effect link between exercise and lower medical costs. But they do say that it provides “strong evidence of the association.” In fact, they point out, because cardiovascular disease and its risk factors were self-reported (and not everyone knows they have them), those numbers were likely to be lower in the survey than in real life. “As a result, the estimates in our study are likely to be conservative,” they wrote.

“The message to the patient is clear,” said Dr. Nasir: “There is no better pill in reducing the risk of disease and health care costs than optimizing physical activity.”