5. Two cars, A and B, start from points $A$ and $B$ respectively and travel in the same direction. If car A travels at 50 kilometers per hour, it will catch up with car B in 6 hours; if it travels at 80 kilometers per hour, it will catch up with car B in 2 hours. From this, we can determine that the speed of car B is $\qquad$ kilometers per hour.
【Analysis】Let the speed of car B be $x$ km/h. From the formula for the distance in a catch-up problem, which is distance difference $=$ speed difference $\times$ time, we get $(50-x) \times 6=(80-x) \times 2$
$$
\begin{aligned}
300-6 x & =160-2 x \\
140 & =4 x \\
x & =35
\end{aligned}
$$