Let's separate the problem in two parts:
Part 1): Collision between the stone and the block.
In the collision, the total momentum of the system stone+block is conserved.
Before the collision, only the stone is moving, so the total momentum is:

where

is the mass of the stone and

is the speed of the stone, traveling towards the block (to the right).
After the collision, both the stone and the block are in motion, so the total momentum is:

where

is the new speed of the stone (with a negative sign, since the stone is now moving in the opposite direction, to the left),

is the mass of the block and

is the mass of the block just after the collision.
Since the momentum must be conserved,

So we can rewrite everything

to find


So the block slides with speed 2 m/s to the right after the collision.
Part 2) Block compressing the spring
At this point we can ignore the stone and focus only on the block and the spring. The block starts to move with speed 2 m/s, so its kinetic energy is

As it compresses the spring, the speed of the block decreases and its kinetic energy is converted into elastic potential energy of the spring, which undergoes through a compression

with respect to its rest position. When the block completely stops, the compression of the spring is maximum,

, and the elastic potential energy of the spring is:

where

is the constant of the spring.
For the conservation of energy, we must have

So we can write

and we can solve to find the compression of the spring: