I found out I was unexpectedly pregnant the day after my 31st-birthday party. My boyfriend and I could still measure our relationship in weeks, and I was living alone in a sparsely furnished one-bedroom apartment in Calgary. I had just wrapped up a tumultuous first year of self-employment as a personal-finance blogger but had yet to master the seemingly impossible task of issuing myself a regular paycheque. Even though I had money saved (obvs, I follow my own advice), my monthly income was feast or famine. There were times when I earned enough that my bank account looked like I’d received a small inheritance from a reclusive long-lost uncle, but other months I barely brought in enough to cover my rent. In other words, I felt nowhere near financially ready for a baby.

I wasn’t emotionally ready either. I had breezed through my 20s racking up degrees and job titles, operating under the naive belief that I was too responsible and accomplished for any major life event to catch me by surprise. Getting accidentally pregnant felt profoundly careless, even though I had been totally careful. (PSA: The 2 percent failure rate of condoms is no joke.) The magnitude of responsibility was crushing, as was the price tag. According to Statistics Canada, the average cost to raise a child from birth to age 18 is approximately $250,000, which made my sudden situation feel a lot like being signed up for a mortgage while I was sleeping.

The upside to pregnancy is, unlike, say, covering a broken dishwasher, you have nine months to save money before your baby arrives. You can breathe a little easier when you realize that you don’t have to buy maternity-wear until your second trimester and your first daycare bill won’t come due for a while. While my body and my future no longer belonged entirely to me, my money still did—for now. And I had to make the most of it. Budgeting isn’t glamorous, but when the unexpected strikes, the degree of predictability it provides is exactly what you need to stay sane. With the help of friends, family and Google, I made a list of all the one- time purchases and monthly costs that come with having a baby. I then reconciled my income with my upcoming new expenses to determine what I could afford and what I could save.

Thankfully, drastic life changes often lead to drastic spending changes. My wine budget instantly became $0, and exhaustion and nausea during pregnancy forced my dining-out budget to dwindle right after it. My favourite stores didn’t carry maternity clothes, so I didn’t even feel the urge to shop when I walked through a mall. Instead, I spent time browsing online sales and seeking out consignment stores, looking for a wardrobe inexpensive enough to justify wearing it for only a few months. I quickly grew accustomed to quiet nights in, trading the fast-paced excitement of my childless years for the calm preparation of welcoming a little someone new. My lifestyle changed so much that even without putting any restrictions on my spending, money started accumulating in my bank account—one of the perks of a boring social life, I guess.

I set up a dedicated “baby fund” to capture that cash I was no longer spending. Every Monday, I transferred $50 from my chequing account to this fund. I still use it to this day. It’s true that $50 won’t solve all your financial woes, but it can slowly but surely make a difference. Once my daughter was born, additional sources of income, like the Canada child benefit, which is a monthly payment from the government to Canadian families, and child support from my baby’s father, helped with my new expenses. (FYI: Canada.ca has a list of all the benefits and tax credits you’re entitled to as a parent.) Not having to worry about paying my bills while trying to get the hang of motherhood (sleep deprivation, learning to breastfeed, all that good stuff) meant that my attention was focused where it was needed: on my baby.

But my time off didn’t last long. Since I’m self-employed, I really couldn’t afford to take more than a three-month maternity leave from my company. To make the transition easier, I returned to work slowly, starting out with only three hours a day, two days a week. Between our breastfeeding schedule and the parental separation anxiety I battled in those early months, I physically couldn’t do more. But as my daughter grew and I learned how to integrate work back into my life, it got progressively easier. Now, when my mom friends lament jumping back into 40-hour workweeks after a year off with their babies, I’m glad I had the luxury of rearranging my life around my new role as a mother on my own time.

My daughter’s first birthday is rapidly approaching. Our days have now settled into a peaceful routine of work and play, and it’s hard to remember a time when I worried whether I’d be able to make it. We don’t always get to choose what happens to us, financially or otherwise, but we can control how we respond to it. My diligent budgeting and planning paid off—and because of that I was able to make unexpected parenthood part of my ordinary life. It’s proven to be as expensive as promised, but it’s also turned out to be the best investment I’ve ever made.

This article first appeared in the June issue of ELLE Canada.