According to law conservation of momentum,

This means the total momentum before and after the collision is equal.
In the above equation, m1 and m2 are the mass of two bodies. v1i and v2i are the initial velocities of the bodies. And v1f and v2f are the final velocities of the bodies.
The values of these quantities are as follows
![m_1=2.0\operatorname{kg},\text{ }v_(1i)=5.0m/s,v_(2i)=0\text{ m/s, },v_(1f)=0.25m/s,v_(2f)=1\text{ m/s}]()
m2 is the value we need.
Substituting all the known values in the equation we get,

On simplifying the above equation,

i.e.

Hence the mass of the second cart is 9.5 kg