The gravitational force acting on both the masses is the same. We know that
Force $$=$$ mass × acceleration.

For same force, $${\text{acceleration}} \propto \frac{1}{{{\text{mass}}}}$$
$$\therefore \frac{{{a_{5M}}}}{{{a_M}}} = \frac{M}{{5M}} = \frac{1}{5}\,.....(i)$$
Let $$t$$ be the time taken for the two masses to collide and $${x_{5M}},\,\,{x_M}$$ be the distance travelled by the mass $$5\,M$$ and $$M$$ respectively.
For mass $$5\,M$$
$$\eqalign{
& u = 0,\,\,\,S = {x_{5M}},\,\,\,\,t = t,\,\,\,a = {a_{5M}} \cr
& \therefore S = ut + \frac{1}{2}a{t^2} \cr
& \Rightarrow {x_{5M}} = \frac{1}{2}{a_{5M}}{t^2}\,.....\,(ii) \cr} $$
For mass $$M$$
$$\eqalign{
& u = 0,\,\,\,s = {x_M},\,\,\,\,t = t,\,\,\,a = {a_M} \cr
& \therefore s = ut + \frac{1}{2}a{t^2} \cr
& \Rightarrow {x_M} = \frac{1}{2}{a_M}{t^2}\,.....\,(iii) \cr} $$
Dividing (ii) by (iii)
$$\eqalign{
& \frac{{{x_{5M}}}}{{{x_M}}} = \frac{{\frac{1}{2}{a_{5M}}{t^2}}}{{\frac{1}{2}{a_M}{t^2}}} = \frac{{{a_{5M}}}}{{{a_M}}} = \frac{1}{5}\,\,\,\,\,\,\,\,\,\left[ {{\text{From }}(i)} \right] \cr
& \therefore 5{x_{5M}} = {x_M}\,.....(iv) \cr} $$
From the figure it is clear that
$${x_{5M}} + {x_M} = 9R\,.....(v)$$
Where $$O$$ is the point where the two spheres collide.
From (iv) and (v)
$$\eqalign{
& \frac{{{x_M}}}{5} + {x_M} = 9R \cr
& \therefore 6{x_M} = 45R \cr
& \therefore {x_M} = \frac{{45}}{6}R = 7.5R \cr} $$