Let $x$ be the distance of the locomotive from the crossing at the moment of whistling. The train covered this distance in $\frac{x}{20} \mathrm{~s}$, while the sound of the whistle took $\frac{x}{340} \mathrm{~s}$.

The train arrived at the crossing $4 \mathrm{~s}$ later than the sound, that is,

$$
\frac{x}{20}-4=\frac{x}{340}
$$

from which $x=85 \mathrm{~m}$, which is the distance the locomotive was from the crossing when it started whistling.
A train approaching at a speed of $20 \mathrm{~m} / \mathrm{s}$ sounded its horn at the railway crossing. We heard the horn 4 seconds before the train arrived. How far was the train when it started to sound the horn? (The speed of sound is $340 \mathrm{~m} / \mathrm{s}$.)