2. The express passenger train, two days ago in the morning, departed from Gevgelija to Skopje, with several carriages in which there was a certain number of passengers. At the station in Veles, one passenger disembarked from the first carriage, two passengers disembarked from the last carriage, and no passengers boarded. Departing from Veles, in each carriage of the train, there was an equal number of passengers. The same train, with two fewer carriages, in the afternoon departed from Skopje to Gevgelija with 50 fewer passengers compared to the passengers who started the journey that morning from Gevgelija. At the same time, the average number of passengers per carriage was 30. How many passengers started the journey that morning from Gevgelija?
Solution. Let $n$ be the number of carriages, and $x$ be the total number of passengers on the train traveling on the route Gevgelija-Skopje. If one passenger disembarks from the first carriage, and two passengers disembark from the last carriage, then the total number of passengers will be $x-3$, and the number of passengers in one carriage on the route Gevgelija-Skopje will be equal to $\frac{x-3}{n}=k, k \in \mathbb{N}$, which means $x-3=k n$.

On the route Skopje-Gevgelija, the number of carriages is equal to $n-2$, and the total number of passengers is equal to $x-50$. From the condition that the average number of passengers per carriage is 30 on the route Skopje-Gevgelija, we get $\frac{x-50}{n-2}=30$, or $x-50=30(n-2)$.

From $x-3=k n$ and $x-50=30(n-2)$, we obtain the system

$$
\left\{\begin{array}{l}
x=k n+3 \\
(30-k) n=13
\end{array}\right.
$$

From the second equation of the system, we get $30-k=1, n=13$ or $30-k=13, n=1$, which means $k=29, n=13$ or $k=17, n=1$.

From the condition of the problem, it follows that $n \geq 3, k \geq 1$, so the only solution to the problem is $k=29, n=13$. According to this, $x=29 \cdot 13+3=377+3=380$, which means the number of passengers who boarded the train that morning from Gevgelija is 380.