Apply the residue theorem to the logarithmic derivative $\frac{f'}{f}$. Its residues are exactly the orders of the zeros and poles of $f$, so the integral counts them, and it also measures how many times the image curve $f(C)$ winds around $0$.
Key idea
Argument principle. If $f$ is analytic on and inside $C$ except for finitely many poles inside, and has no zeros or poles on $C$, then
$$\frac{1}{2\pi i}\oint_C\frac{f'(z)}{f(z)}\,dz = Z - P,$$
where $Z$ and $P$ count the zeros and the poles inside $C$, each counted with its multiplicity. This number is also the number of times $f(C)$ winds around $0$ (counterclockwise positive).
Why it works
Near a zero of order $m$, $f = (z - a)^mg$ with $g(a) \ne 0$, so $\frac{f'}{f} = \frac{m}{z - a} + \frac{g'}{g}$: residue $m$. Near a pole of order $m$, $f = (z - a)^{-m}g$ and the residue is $-m$. Adding up gives $Z - P$. On the other hand, $\frac{f'}{f} = \frac{d}{dz}\log f$, so the integral measures the total change of $\log f(z)$ around $C$: the change in $\ln|f|$ is $0$, and the change in $\arg f$ is $2\pi$ times the winding number of $f(C)$ around $0$.
Worked examples
Worked example: Counting with multiplicity
For $f(z) = \dfrac{(z - 1)^2(z + 3)}{(z - 2i)^3}$, find $\dfrac{1}{2\pi i}\displaystyle\oint_{|z| = 2.5}\frac{f'}{f}\,dz$.
- Zeros: $1$ (order 2, inside) and $-3$ (outside). So $Z = 2$.
- Pole: $2i$ (order 3, inside, since $|2i| = 2 < 2.5$). So $P = 3$.
- $Z - P = 2 - 3 = -1$: the image curve winds once clockwise around $0$.
Answer: $-1$
Worked example: A power
How many times does $f(C)$ wind around $0$ for $f(z) = z^5$ and $C$: $|z| = 1$?
- $z = e^{it}$ gives $f = e^{5it}$: the image goes around the unit circle $5$ times.
- Also $Z - P = 5 - 0$ (a zero of order $5$ at $0$).
Answer: $5$
Worked example: A factorable polynomial
Compute $\displaystyle\oint_{|z| = 3/2}\frac{f'}{f}\,dz$ for $f(z) = z^3 - z^2 + 4z - 4$.
- Factor: $f = z^2(z - 1) + 4(z - 1) = (z - 1)(z^2 + 4)$, with zeros $1$, $2i$, $-2i$.
- Only $1$ is inside $|z| = \frac{3}{2}$, so $Z = 1$, $P = 0$.
- The integral is $2\pi i \cdot 1 = 2\pi i$.
Answer: $2\pi i$
In practice the winding number is often read off a picture of $f(C)$, or estimated numerically, and then the argument principle tells you how many zeros lie inside: a standard way to locate roots of polynomials and to test the stability of control systems.
Common mistake
Counting a zero once regardless of its multiplicity, or forgetting the poles. A double zero contributes $2$, a triple pole contributes $-3$. In the first example, counting "one zero, one pole" would give $0$ instead of $-1$. Write each zero and pole with its order next to it before adding.