Kevin O'Leary: Follow this rule to figure out how much you should spend on housing

Whether you're looking to rent or own your next , Kevin O'Leary says there's an easy way to determine how much you can afford to pay.

The judge of CNBC's " Court" tells CNBC that renters and buyers alike need to follow what he calls the "one third-one third-one third" rule, which calls for a third of your after- income to go toward living expenses, a third toward your home and the last third toward savings and investments.

That means that a person earning $3,000 a month after taxes shouldn't spend more than $1,000 on housing.

"If you let the house that you're buying's mortgage payment or the place you're renting be more than a third of your after-tax cash flow, you're going to put tremendous on yourself," O'Leary says. "That means you may have to live in a smaller apartment if you're renting, or buy a smaller home to start."

O'Leary's advice is similar to the general rule that dictates you should spend no more than 30% of your gross monthly income on housing. However, his recommendation allocates a slightly higher percentage and uses post-tax income. The government has recommended that people spend no more than 30% on housing costs since 1981, and considers people who spend more "cost burdened."

For renters, that 30% includes rent and utility costs like heat, water and electricity, CNBC Make It previously reported. For homeowners, that figure includes homeowners insurance, as well as property taxes, utilities and your mortgage.

In expensive cities with high rent , O'Leary admits that it may be difficult to stick to the "one third-one third-one third" rule. If you're planning to buy a home, it's better to be patient and wait for one within your budget than to spend more than you can afford, he says.

"There's nothing wrong with buying a smaller home, living there for five years, selling it and buying a bigger home as your income goes up or you get married and you have two incomes," he says.

Aspiring homeowners should also be conscious of the the 28/36 rule, which stipulates that your housing expenses shouldn't exceed 28% of your gross monthly income while your total debt, including and loans, shouldn't exceed 36% of your monthly income.