Question about solution to Morin Leaky Bucket problem

In Morin’s Mechanics book, a problem called leaky bucket goes:

5.17. Leaky bucket ** At $$t = 0$$, a massless bucket contains a mass $$M$$ of sand. It is connected to a wall by a massless spring with constant tension $$T$$ (that is, independent of length).25 See Fig. 5.23. The ground is frictionless, and the initial distance to the wall is $$L$$. At later times, let $$x$$ be the distance from the wall, and let $$m$$ be the mass of sand in the bucket. The bucket is released, and on its way to the wall, it leaks sand at a rate $$dm/dx = M/L$$. In other words, the rate is constant with respect to distance, not time; and it ends up empty right when it reaches the wall. Note that $$dx$$ is negative, so $$dm$$ is also.

(a) What is the kinetic energy of the (sand in the) bucket, as a function of $$x$$? What is its maximum value?

(b) What is the magnitude of the momentum of the bucket, as a function of $$x$$? What is its maximum value?

In the solution, it starts:

The initial position is x = L. The given rate of leaking implies that the mass of the bucket at position x is m = M(x/L). Therefore, F = ma gives −T = (Mx/L)x ̈.

My question is, how can they use F=ma? Wouldn’t you need to know the speed that the mass is being ejected, and then use F = dp/dt? I understand that the solution must be correct, but I don’t get why F=ma is valid to use. I’d appreciate any explanation. Thanks!