Relative velocity between the trains is 20 kmph =>
20×5/18 m/s => 50/9 m/s
Now length of the faster train is
(50/9){speed}×(5){time}
Because from the passenger's point of view, the faster train is moving at only the relative velocity and it took 5 seconds for it to pass by him
Therefore the length of the faster train is [27 (7/9)] meters.