Two trains each travelling at a speed of 20 kmph approach each other on the same straight track. A bird that can fly at a speed of 40 kmph flies off from one train when they are 40 km apart and heads directly for the other train. On reaching the other train it flies directly back to the first train and so forth. Before the trains crash, the total distance travelled by the bird is