Example 3-2 A school only offers three courses: Mathematics, Physics, and Chemistry. It is known that the number of students taking these three courses are 170, 130, and 120, respectively. The number of students taking both Mathematics and Physics is 45; the number of students taking both Mathematics and Chemistry is 20; the number of students taking both Physics and Chemistry is 22; and the number of students taking all three courses is 3. Try to calculate the total number of students in the school.
Let $M$ be the set of students studying mathematics, $F$ be the set of students studying physics, and $C$ be the set of students studying chemistry. It is given that:
$$
\begin{array}{l}
|M|=170, \quad|F|=130, \quad|C|=120, \quad|M \cap F|=45, \\
|M \cap C|=20, \quad|F \cap C|=22, \quad|M \cap F \cap C|=3 .
\end{array}
$$

The number of students in the school is
$$
\begin{aligned}
|M \cup F \cup C|= & |M|+|F|+|C|-|M \cap F| \\
& -|M \cap C|-|F \cap C|+|M \cap F \cap C| \\
= & 170+130+120-45-20-22+3=336
\end{aligned}
$$