When net force acting on a system of bodies is zero or there is no external force acting on an isolated system of bodies, the momentum of the bodies remains same.
Let two bodies collide with momenta being p1 and p2 respectively before collision. Let their momenta after collision be p1' and p2'. Then,
total momenta before collision = total momenta after collision
p1 + p2 = p1' + p2' Vector addition is to be used.
in terms of velocities, M1 U1 + M2 U2 = M1 V1 + M2 V2
where M1 & M2 are masses, U1, U2 are velocities before collision and V1, v2 are velocities after collision.