A person is traveling from city A to city B by car. He travels the first 40 of the distance at a speed of 60km/h, the next 30 at a speed of 90km/h, and the remaining distance at a speed of 75km/h. The entire trip takes him 5 hours. What is the total distance between city A and city B?