Suppose the slide has minimum initial speed $u$. In the frame of reference of the slide, the mass $m_2$ must have barely any kinetic energy left when it reaches the top of the slide. In other words, the slide and the mass must have the same speed $v$ in the original frame of reference when the mass reaches the top. From conservation of momentum,