A bag (mass M) hangs by a long thread and a bullet (mass m) comes horizontally with velocity v and gets caught in the bag. Then for the combined (bag + bullet) system
Initial momentum = mv
Final momentum = (m + M)V
By conservation of momentum mv = (m + M)V
∴ Velocity of (bag + bullet) system V = mvM+m
∴ Kinectic energy = 12(m+M)V2
=12(m+M)(mvM+m)2=12m2v2M+m