Sorry, but these two statements (“no more than 40k” and “any amount”) appear to contradict each other. You need to determine what the hard limit is without taking on an unreasonable amount of debt. It is not worth taking on a truckload of debt no matter how prestigious the school you get into is. Additionally, you need to have money available for your master’s degree so take that into account as well.