forget the hcv solution i did it this way.
force on M block F-kx/M=a
NOW SITTING ON THAT BLOCK m dv/dt =kx-m(F-kx/M). multiply by dx on both sides n integrate .on the velcity side integrate from 0 to 0 since at maxcompression v relative =0
2F/(m+M)k=x