TITLE: Famous uses of the inclusion-exclusion principle?
QUESTION [16 upvotes]: The standard textbook example of using the inclusion-exclusion principle is for solving the problem of derangement counting; using inclusion-exclusion (and some basic analysis) it can be shown that $D(n)=\left[\frac{n!}{e}\right]$ which I consider to be quite a beautiful example since it tackles a problem that does not seem to be solvable with such a closed formula in the first place (and also, who expects inclusion-exclusion to yield a closed formula?)
Another standard textbook use is giving a (non-closed) formula for Stirling numbers. This result is less amazing, but is still important enough.
My question is whether there are other nice such examples for using inclusion-exclusion for dealing with "natural" and "famous" problems, preferably problems arising in other fields in mathematics.
Edit: I just remembered another nice example: Proving the formula for $\varphi(n)$ (Euler's totient function) directly (there are other methods as well).

REPLY [3 votes]: Here is an inclusion-exclusion based on max and min: for any
 finite set $(T_s)_{s\in {\cal S}}$ of numbers 
we have 
$$\bigvee_{s\in {\cal S}} T_s =\sum (-1)^{|A|-1} \bigwedge_{s\in A} T_s\tag1$$
where the sum runs over all non-empty subsets $A$ of $\cal S$.
If $(X_n)$ is a Markov chain with state space ${\cal S}$, 
and $T_s:=\inf(n\geq 0: X_n=s)$ is the hitting time of state $s$, 
then the left hand side of (1) is called the cover time. 
It's the number of steps until every state in ${\cal S}$ is hit.  
Calculating the average cover time for a Markov chain is considered a pretty tough problem. In contrast, finding the average of the time $\wedge_{s\in A}\ T_s$
to hit a subset $A$ is fairly standard. That's why I was very surprised to 
learn the connection between these two problems via (1). 
I first saw this in Robert Israel's beautiful answer to this MO question.