The initial elastic potential energy stored in the spring is:

Then, the spring is released, all this potential energy is converted into kinetic energy of the eraser:

Then, the force of friction does a work to stop the eraser in this motion, and this work is equal to

where F is the magnitude of the friction force and d is the distance covered by the eraser.
For energy conservation, the work done by the friction force must be equal to the initial energy of the eraser, so:

and so we find d:
