A billiard table. (see picture)
A white ball is on $p_1$ and a red ball is on $p_2$. The white ball is shot towards the red ball as shown on the pic, hitting 3 sides first. 
Find the minimal distance the ball must travel.

[img]http://www.mathlinks.ro/Forum/album_pic.php?pic_id=280[/img]
1. **Reflect the table:**
   - To simplify the problem, we reflect the billiard table across its sides. This allows us to transform the problem of the ball hitting the sides into a straight-line distance problem.
   - Reflect the table such that the ball travels in a straight line from the initial position to the final position after hitting the sides.

2. **Calculate the total vertical distance:**
   - The ball travels vertically a distance of 16 units (first segment) and then 12 units (second segment).
   - Therefore, the total vertical distance is:
     \[
     y_{\text{total}} = 16 + 12 = 28 \text{ units}
     \]

3. **Calculate the total horizontal distance:**
   - The ball travels horizontally a distance of 6 units (first segment), then 18 units (second segment), and finally 4 units (third segment).
   - Therefore, the total horizontal distance is:
     \[
     x_{\text{total}} = 6 + 18 + 4 = 28 \text{ units}
     \]

4. **Calculate the straight-line distance:**
   - Using the Pythagorean theorem, the straight-line distance \(d\) is given by:
     \[
     d = \sqrt{(y_{\text{total}})^2 + (x_{\text{total}})^2}
     \]
   - Substituting the values:
     \[
     d = \sqrt{28^2 + 28^2} = \sqrt{2 \cdot 28^2} = 28\sqrt{2}
     \]

Conclusion:
\[
\boxed{28\sqrt{2}}
\]