Did you remember to include the kinetic energy of chain in the final kinetic energy? This should contain the mass of chain, and so help you to eliminate it from the expression for initial potential energy.
Just in case you still or others who are doing this need further help. You are on the right track to use the conservation of energy. Initially, the system (heavy chain, the 2 masses and earth) has only gravitational potential energy (GPE). Finally, the system has GPE and KE. You need to be careful in writing the initial and final GPE of the system. There is more than one way of writing the initial and final GPE of the system, but it does not change the final answer. The final speed does not depend on the m or 3m.