I wouldn't try putting an M5 motor as everything I've heard about that swap says that it is hard and complicated, and as far as I know, only one shop has ever done it. If I wanted a more powerful M62 motor, I'd get an M62 motor and supercharge it, but I'm not sure how much superchargers go for now, and I'm not sure how much money would be left over from the motor swap. I would think a supercharged M62 would get around the same power as a stock M5.
The first thing I would reccomend, is to use that money to fix all items in the car that need to be fixed, starting with the motor, then moving on to maintenance. Also, while the motor you are going to replace the blown one with is out of the car, that would be the best time to replace the many maintenance related items on the motor that are known to go bad, such as OSV/PCV systems, timing chain guides and tensioners, valve cover gaskets, valley pan gasket, motor mounts, front suspension items, etc.