Calculation ofP2shape resonances in Be and Mg