The first thing I would do is to multiply everything by 3 to get rid of the fraction:
3M = 3wp + yp²
We can then take the 3M over to the other side to leave a quadratic equation:
yp² +3wp - 3M = 0
The easiest way to solve this for p is to use the quadratic formula:
p = ± (√(9w²+12yM))/2y