2004 Mazda 6s Wagon 3.0L, will 2005 MPV 3.0 fit.....

Mazda Protege5 2002 Sport Mazda6s wagon 2004
I just bought this car knowing it needed an engine......Looking around for a used engine finding that the exact motor for the car from the same year has hella miles on it and I didnt want to buy a new motor. I have found a ton of MPV motors with much lower mileage and cheaper. Will they fit and is it the same as the 6 motor.

I would appreciate some tech advice from some of the knowledgeable people here....Im currently driving a 2002 Protege5 its got over 230k on it and Im looking to keep it and drive it until it actually falls apart and I picked up this 6 wagon for cheap.

Thanks for reading and hope to gain some useful info