solve train length task