Martha Ryan couldn't believe it. She had never heard of women who were pregnant and homeless.

But in one night, she met three.

"I said, 'How could that be?' " recalled Ryan, who was volunteering at a San Francisco shelter at the time while pursuing her master's degree in public health. "But it didn't take me long to realize that ... if they were poor, they probably wouldn't have health care, but certainly (they) would still be having sex. And they would get pregnant."

Ryan also realized the likely consequences.

None of the three women had received prenatal care, meaning they were far more likely to deliver unhealthy babies. An unhealthy baby would add to the burdens of a homeless mother, and the family would likely end up dependent on state programs to survive.

"If they delivered unhealthy babies that ended up in the intensive care nursery ... (that) could have cost the system, the society, the taxpayer, all of us," Ryan said. "(And) the continual costs through a child's life -- of needing more support -- is astronomical."

Preventive care, it seemed, would be much more effective, and Ryan recognized an opportunity to help these women change their lives. She took a grant-writing class and eventually secured the $52,000 she needed to start her Homeless Prenatal Program.

Since 1989, the nonprofit has provided prenatal care to thousands of homeless women in San Francisco. But it's also grown to offer much more.

Martha Ryan, left, has helped more than 80,000 families since she started her program more than 20 years ago.

"I learned very early on that prenatal care alone was not enough," said Ryan, a 63-year-old registered nurse. "The women that we were serving needed help with housing, mental illness, substance abuse, domestic violence. ... And if we didn't help her with these other issues, then we were not going to be able to help her long term or help her children exit poverty."

Today, Ryan's group assists more than 3,600 families per year, offering all sorts of free services to help them pull themselves out of poverty and end a cycle that can repeat itself from generation to generation.

"If you're in (poverty) and you don't have opportunities or ways to climb out of it, it's hard to get out," Ryan said. "When people are given opportunities, they do it. They blaze that trail."

By helping families out of poverty, the nonprofit is also benefiting society and taxpayers.

Ryan said her costs average less than $5,000 per family per year. The city of San Francisco, on the other hand, reports spending an average of $6,647 a year on medical care alone for every person who is consistently homeless.

The assistance also keeps children out of foster care.

"It's a terrible loss for any mother to lose her child," Ryan said, "and often they will replace it with another baby. And so, it's in all of our best interests -- especially the mother and the child -- to keep the family together and to help the mother be the best mother that she could possibly be."

Ryan's program has helped more than 80,000 families since it started, and it has earned the trust of local governments: While some of its annual budget comes from individual and corporate donations, more than half of it comes from city and state grants.

"The government sees us as their partner, and they trust us," Ryan said. "They know that we work with integrity. They know that the work that we do is good, and they see the effects of our work."

Ryan's program has also earned the trust of its clientele.

"This program works," said Carrie Hamilton, describing herself as a former meth addict who lived in a minivan with her young daughter nearly a decade ago. When Hamilton lost her job and got pregnant again, she knew something needed to change.

She reached out to Ryan's group and got help kicking her addiction, delivering a healthy baby, securing housing and stabilizing her life. She went through a year of job training with the group, and now she's part of the staff, working as an outreach and case manager as well as a health educator.

"I am so happy to be able to relay the things I've learned to moms now, especially ones I can relate to because I know where they've been," Hamilton said. "They really listen, not because they fully know where I've come from, but just because I am able to meet them where they are and have a no-judgment feeling for them."

Ryan said nearly a third of her staff is made up of former clients.

"(They) are the reason why this program is what it is today," Ryan said. "When a client comes in and sits down with a case manager who looks like her, who was in her shoes not that very long ago and who is now employed and working, immediate trust is formed. ... She gives her hope, hope that, 'If she did it, why couldn't I?' "

For Ryan, believing and investing in women such as Hamilton is the key to her organization's success.

"Seeing their strength and their ability to pull themselves up and, against all odds, to move forward and to change their lives, now that is inspiring."