Usually friction is denoted by the greek letter μ, and two different quantities don't usually have the same variable representing them. If the coefficient of friction is indeed M (dimensionless), and mass is M (kg), then initial speed is P/M and deceleration is Mg. Using v square = u square + 2as, stopping distance is Psquare/(2 *Mcube *g)
Kinetic energy in terms of momentum = P^2/ (2*m); energy loss due to friction in case of horizontal = coefficient of friction * mass * g(9.81) * horizontal distance. Put it equal and just calculate the value of horizontal distance. That would come out P^2/(2*m^2*g*M). There is one good example in I.E. Irodov, question 1.121, it would give you the proof of the second line.
The stopping distance would be P^2/(2xgXM^3). You can derive it in following manner : Total loss of Kinetic Energy would be equal to the work done by friction force. i.e 1/2 x M x V^2 = M(coeff. of friction) x M(mass) x g(gravity) x S (distance travelled). Now P(momentum) = MxV so you can put V = P/M in above equations and get value of 'S' in terms of 'P' and 'M' .