If you think you’re ready to buy a house, here’s exactly how to calculate the amount you can afford.