A man has to travel a certain distance. When he has travelled 40kms., he increases his speed by 2km/h. If he had travelled with his increased speed during whole of his journey, he would have arrived 40 mins. earlier; but if he had continued at his original speed, he would have arrived 20 mins. earlier. Find the distance he had to travel in kilometres.