hint:

M must be stationary, so you can find the tension in the rope