Two balls of mass $m_1$ and $m_2$ hang on long identical threads. Between them is a compressed spring, which is held in a compressed state by a connecting thread. Potential energy of spring deformation $U$. The thread connecting the spring is burned out. Find the maximum height to which the balls will rise.