Proof (valency theorem)
The principle of isolated zeros implies for each $y\in Y$, the set $f\inv(y)$ is discrete. As $X$ is compact, $f\inv(y)$ is finite. Therefore we can define $$ \begin{align*} n(y) = \sum_{x\in f\inv(y)} d_x. \end{align*} $$ To show $n$ is constant on $Y$, as $Y$ is connected, it suffices to find, for all $y$, a neighbourhood of $y$ where $n$ is constant.
Fix $y\in Y$. For each $x\in f\inv(y)$, by local mapping theorem, find open neighbourhoods $U_x\ni x$ and $V_x\ni y$ such that $f|_{U_x\setminus \set{x}}: U_x \setminus \set{x} \to V_x \setminus \set{y}$ is surjective and $d_x$-to-1. By shrinking $U_x$, assume $\sb{U_x}{x\in f\inv(y)}$ are disjoint.
Let $$ \begin{align*} V := \biggl(\bigcap_{x\in f\inv(y)} V_x\biggr) \setminus f\Bigl(X \setminus \bigcup_{x\in f\inv(y)} U_x\Bigr). \end{align*} $$ Because $X\setminus \bigcup_{x\in f\inv(y)} U_x$ is closed, it is compact, so its image under $f$ is compact hence closed. Therefore $V$ is an open neighbourhood of $x$.
For all $y'\in V\setminus \set{y}$, note by construction $f\inv(y') \subseteq \bigcup_{x\in f\inv(y)} U_x$, so all $x'\in f\inv(y')$ are unramified. Thus $$ \begin{align*} n(y') = \# f\inv(y') = \sum_{x\in f\inv(y)} \#(f\inv(y') \cap U_x) = \sum_{x\in f\inv(y)} d_x = n(y). \end{align*} $$ Hence $n$ is constant on $V$.