Dementia and Alzheimer’s disease generally strike late in life. But researchers say that what you do when you are younger — including activities like reading and gardening — can affect your risk of developing these conditions.

In a new study published in the journal Neurology, researchers in Sweden found that mentally stimulating activities and physical exercise can independently lower people’s chances of developing many types of dementia, as well as Alzheimer’s disease.

The study included 800 women who were on average 47 years old at the start of the study, and researchers followed them for 40 years. At the beginning of the study, the women answered questions about their mental and physical activities. Mental endeavors included everything from reading to visiting a museum, attending a concert, playing an instrument, doing needlework, being part of a club and attending church. Physical activities included walking, gardening, playing tennis, cycling, swimming or participating in competitive sports. Based on how often they did these activities, the scientists ranked them as high or low participants. Six times over the course of the study, the women took cognitive tests to assess their mental acuity, and the researchers collected information on any dementia diagnoses during this time.

The women who engaged in more mental activities lowered their risk of developing any type of dementia by 34% compared to those who reported doing fewer mental activities. And women who exercised regularly at intense levels several times a week had a 57% lower risk of developing a combination of Alzheimer’s dementia and dementia compared to those who exercised less.

“We hope these results give people hope,” says the study’s lead author Dr. Jenna Najar, from the Institute of Neuroscience and Physiology at the University of Gothenburg’s Sahlgrenska Academy. “Dementia is a growing problem in the world, and there is no treatment or cure for this disease. This study shows that it seems that mental activity is as important as physical activity to preserve or increase the chances of healthy aging.”

Similar studies that have looked at the link between physical or mental activity and dementia have not usually included as long an observation period as the new analysis does. Most of those studies also start with people who were much older and who were potentially already affected by different types of dementia.

In her analysis, Najar adjusted for the fact that some of the women in the study might already be experiencing early signs of dementia. She also found that exercise and mental activities lowered dementia risk independently of each other. The benefit of mental activities occurred regardless of how much physical activity the women did. And the same pattern held for exercise; women who were more active experienced benefit no matter how much mental activity they did.

The results support the findings of another recent study: that while attaining more education isn’t necessarily linked to a lower risk of dementia, being cognitively active in mid-life and later — when aging-related dementia processes start — could reduce risk.

Najar was not able to look at whether women who were highly engaged in both mental and physical activities had an even lower risk of dementia. (It’s possible that they might, she says.) She adds that her study only asked about the women’s activities at one point in time and assumed those patterns continued for most of their lives.

Still, she says, the findings should give doctors more reason to discuss both mental and physical activities with their patients who are concerned about dementia — and start discussing them by midlife, years before the first signs might appear.

Contact us at letters@time.com.