What will be the condition of no collision between the two trains?

Two trains are coming towards each other along the same line with velocity #u_1# and #u_2# respectively. When the distance between them is #s#, both drivers apply breaks to create retardation #r_1# and #r_2# respectively.