What will be the condition of no collision with the second train?

The drivers of a train moving at a speed #v_1# sight another train at a distance #d# ahead of him on the same line, moving with slower speed #v_2#. 1st driver pulls the brake to create a retardation #r#.