You'll have to find a Socket 775 mobo, I would look in the line of ASUS P5 series (they made a lot of them, P5Q, P5N, etc etc.) Try newegg and filter down to socket 775 then DDR2 RAM and get an idea of what mobos there are. You'll need something that supports your CPU, so make sure of that (not all chipsets support all CPUs). Any questions, link it and we can take a look.
For reference, the M5640-B5401A specs:http://support.acer.com/acerpanam/desktop/0000/Acer/AspireM5640/AspireM5640sp2.shtml