A ball of rest mass $M$ and relativistic energy $E$ collides elastically with a stationary ball of rest mass $m$, such that the direction of motion is along the line joining the centers of the two balls.

I am asked to show that the final energy of $M$ is given by (when defining c=1 for simplicity)

$E$=(2$m$$M^2$+$E$($m^2$+$M^2$))/(2$m$$M$+$m^2$+$M^2$)

I then tried to square it and make use of the identity:

$E^2$=$m^2$+$p^2$ and equate the momentum components before and after the collision.

However, the equations became exhaustively long and I am unable to reach the final equation I'm trying to proof (in the above). May I ask for some hints or tips of what I'm supposed to do? Perhaps is there another (much simpler) method to tackle this problem?

Thanks.