Let there be p intermediate stations between two terminus stations A and B as shown in the figure.
No. of ways the train can stop in three intermediate stations = pC3
These are comprised of two consecutive cases viz.
(i) At least two stations are consecutive
(ii) No two of which is consecutive
Now there are (p−1) pairs of consecutive intermediate stations.
In order to get a station trio in which at least two stations are consecutive, each pair can be associated with a third station in (p−2) ways. Hence total no. of ways in which 3 stations consisting of at least two consecutive stations can be chosen in (p−1)(p−2) ways. Among these, each triplet of consecutive stations occur twice. For example, the pair (Sn,Sn−1) when combined with Sn+1 and the pair (Sn,Sn+1) when combined with Sn−1 gives the same triplet and is counted twice. So, the number of three consecutive stations trio should be subtracted.
Now, no. of these three consecutive stations trio is (p−2).
Hence, the number of ways the train can stop in three consecutive stations is
= pC3−(p−2)2
=p(p−1)(p−2)1.2.3−(p−2)2
=(p−2)[p2−p−6p+126]
=(p−2)(p2−7p+12)6
=(p−2)(p−3)(p−4)1.2.3
= (p−2)C3
k+m=2+3=5