If you have children, there are probably times when you blame your exhaustion and gray hairs on the stress of parenting. But being a parent has health benefits, too. A new study shows that the demands of parenthood protect your brain from some of the negative effects of aging.

To come to this happy conclusion, Rutgers and Yale researchers looked at the structure and resting state of the brain MRIs of more than 37,000 participants, the largest population-based neuroimaging dataset to date.

The people in the study were part of the UK Biobank, a biomedical database of adults in the United Kingdom between the ages of 40 to 69 years. Nearly 20,000 women and over 17,000 men, all of whom completed information about their age, sex, number of children, education and socioeconomic status took part in the research.

When you're a parent, you're dragged out of your comfort zone. Kids draw us into new experiences and put us into new social situations, exposing us not just to our own children and their friends, but the families of their friends.

Parenting offered the researchers a useful way to see how socializing and changes in our environment affect brain health.

“Parenthood is perhaps one of the most salient and important life events for many individuals,” one of the study's authors, Avram Holmes, associate professor of psychiatry at Rutgers Robert Wood Johnson Medical School, and a faculty member of the Rutgers Brain Health Institute, said in a press release. “It has a massive change in the environment that you find yourself embedded in once children enter into your life, so it's a perfect window to study the extent to which environment can affect brain functioning.”

The findings are good news for parents. They show that parents' brains tend to have stronger functional connectivity. This enables different areas of their brains to actively work together, a cognitive function that typically decreases with age. What's more, this connectivity gets stronger with each child. So, the more kids, the bigger the benefit.

“It does look sort of like a dose response model that you'd find in a typical medical study,” Holmes observed, “where you increase the dosage, you find a larger effect.” However, the protection against cognitive decline doesn't come directly from the number of children a person has; it reflects the social connections and environmental changes that are associated with raising kids.

There may be cognitive benefits for others involved in raising children, like grandparents and childcare workers.

When you're a parent, the researchers say, you're dragged out of your comfort zone. Kids keep us moving and draw us into new experiences and new social situations. We're exposed not just to our own children and their friends, but the families of their friends. As a result, we build a whole rich social environment that our kids help us construct.

This is true for both moms and dads, and possibly also other caregivers. The study's findings suggest that there might be cognitive benefits for other folks involved in raising children, like grandparents and childcare workers.

Parenthood isn't the only way to protect the brain against aging. The National Institute on Aging offers the following ideas for staying mentally sharp, whether you have kids or not. The goal is to stay engaged and find enjoyment in meaningful activities:

The authors note that more long-term and larger-scale research are needed to understand the actual mechanisms behind how parenthood protects brain function. The study examined only biological parents from the U.K., so it can't offer information about how, or if, different parenting roles and family structures might affect brain aging.

The study is published in the journal PNAS, Proceedings of the National Academy of Sciences.