The road leading out of the school runs in the direction 40° to the west of north before joining a main road at a point 400m away from the school. If the junction of the main road runs in a north-south direction, find its shortest distance from the school.