20 minutes = 1/3 hours
let the distance be S
recall that time taken = distance/velocity
so, the time taken when travelling at 30 mph is S/30
and the time taken when travelling at 40 mph is S/40
therefore
S/30 - S/40 = 1/3
multiply through by 120
4S - 3S = 40
S = 40
distance = 40 miles