# Morse index and Euler characteristic

I found the following problem and I couldn't solve it. Let $X$ be a compact manifold and $f$ a Morse function (all of its critical points are non degenerate) on $X$. Prove that the sum of the Morse indices of $f$ at its critical points equals the Euler characteristic of $X$. The Morse index $ind_{x}(f)$ is defined as the sign of the determinant of the Hessian of $f$ at $x$, where $x$ is a critical non degenerate point. Does anyone have an idea? Thank you.

-