Let t=normal time to travel between the two towns.
Distance, s=speed, v*time so although the distance doesn't change, the time does.
40 mph = 40/60 miles per minute=2/3; 30 mph = 30/60 mil per min = 1/2.
When the train is 10mins late we have the equations s=2(t+10)/3=(t+16)/2.
6s=4(t+10)=3(t+16), so 4t+40=3t+48, and t=8. Therefore, s=2*18/3=24/2=12 miles.
(The speed can also be calculated v=s/t=12/8=3/2mi/min=3/2*60=90mph.)