House poverty is real. If you live in a big city with skyrocketing rent (like NYC or San Francisco), chances are you know a few people who are spending most of their income on a place to live and juuust scraping by on what’s left.

The best way to avoid living paycheck-to-paycheck because of rent is to calculate what you should be spending before you even apply for a new place. While fluctuating housing availability and prices can alter how much you may need to pay in your area, ideally you should only be spending around 30% of your income on rent each month.

Figuring out your perfect spending vs. income ratio isn’t just for your own benefit; landlords often look at that same ratio when you apply for a place to make sure they feel confident you can afford it.

Why 30 percent?

Although there’s some debate about how much of your income should be spent on rent, according to the U.S. Census Bureau, the conventional 30 percent rule evolved from the United States National Housing Act of 1937.

After establishing a public housing program, the government set up guidelines to ensure people were not being unfairly charged for rental units. It was decided that in order to qualify for housing assistance, families could not make more than 5-6 times the amount of rent.

As the housing market and economy fluctuated, the Brooke Amendment of 1969 adjusted the guidelines so that the rent threshold was 25 percent of a family’s income instead of the vague “5-6 times” what they earn. In the 80s, that amount evolved to 30 percent and became known as an industry standard for the amount that a household could spend on rent and still have enough left over for other non-discretionary spending.

How to calculate

When you use the 30 percent rule to calculate your ideal rent amount, you should include rent and all related utilities. For example, if you will be paying the water bill you may want to ask your potential landlord what the standard amount is for other tenants in the same building.

A quick shortcut is to take your income (or the total incomes of everyone who will be living with you) and divide it by 40. You can also do it the long way if you love math and figure out 30 percent of your total income and then divide THAT amount by 12.

TIP: Make sure you’re calculating 30% of your take-home pay, not your entire salary.