A train travels between two cities, A and B, that are 240 kilometers apart. The train travels at a constant speed of 80 kilometers per hour for the first half of the journey and then at a constant speed of 60 kilometers per hour for the second half. How much total time does the train take to travel from city A to city B? Let's think step by step and output the final answer within \boxed{}.
user