What's an M3/4/5 ??
If the engine is not hydrolocked, then it's probably salvageable. I would be worried about the electrics, including the engine wiring harness and any sensors, AFM, TPS, etc. If you plan on replacing all of that stuff, just budget accordingly and swap out parts if necessary- then you should be fine.
The basic engine is just an assemblage of mostly metal parts- so as long as the water is out of it and rust is not allowed to set in, you are fine.
If you get it, I would flush out all the fluids, and see what comes out. Put some (a small amount of) light engine oil in each of the spark plug holes and turn the engine over several times. Replace the plugs and see if it will start with fresh gas and oil.
Bret.