Ok, I didn't know where exactly to put my question... but since it's not about school, but a math problem I came across in a competition, I'll put it here. Someone told me the answer was 174 km but that person did it using matlab. The answer was later confirmed after the results of that competition, but I still don't know how is one supposed to do it using only pen and paper and nothing else

Original question:

The country of Big Wally has a railway which runs in a loop of 1080 km long. Three companies, A, B and C run trains on the track and plan to build stations. Company A will build three stations, equally spaced at 360 km intervals. Company B will build four stations at 270 km intervals and Company C will build five stations at 216 km intervals.

The government tells them to space their stations so that the longest distance between consecutive stations is as small as possible. What is this distance in kilometres?

[An approximate sketch I made of the problem]

Thank you in advance