# How do I show the following modification of the Counting formula of zeros and poles?

Let $U\subset \mathbb{C}$ be an open and connected set, $g: U\rightarrow \mathbb{C}$ holomorphic function, $f$ meromorphic function in $U$ with zeros in $z_{1},z_{2},\ldots,z_{n}$ and poles in $p_{1},p_{2},\ldots,p_{k}$. Let $\gamma$ be a closed curve null-homotopic in $U$ and suppose that $\gamma \cap \left\{z_{1},z_{2},\ldots,z_{n},p_{1},p_{2},\ldots,p_{k}\right\}=\phi$. Show that $$\frac{1}{2\pi i}\int_{\gamma}g(z)\frac{f'(z)}{f(z)}dz=\sum_{j=1}^{n}g(z_{j})\mbox{ord}(f,z_{j})\mbox{ind}_{\gamma}(z_{j})-\sum_{j=1}^{k}g(p_{j})\mbox{ord}(f,p_{j})\mbox{ind}_{\gamma}(p_{j}).$$

Remark: The first thing that came to my mind was to use the following theorem:

Theorem (Counting formula of zeros and poles) Let $U\subset \mathbb{C}$ be an open and connected set, $f$ meromorphic function in $U$ with zeros in $z_{1},z_{2},\ldots,z_{n}$ and poles in $p_{1},p_{2},\ldots,p_{k}$. Let $\gamma$ be a closed curve null-homotopic in $U$ and suppose that $\gamma \cap \left\{z_{1},z_{2},\ldots,z_{n},p_{1},p_{2},\ldots,p_{k}\right\}=\phi$. Then $$\frac{1}{2\pi i}\int_{\gamma}\frac{f'(z)}{f(z)}dz=\sum_{j=1}^{n}\mbox{ord}(f,z_{j})\mbox{ind}_{\gamma}(z_{j})+\sum_{j=1}^{k}\mbox{ord}(f,p_{j})\mbox{ind}_{\gamma}(p_{j}).$$

This theorem is very similar to what I want to prove, but I do not know how to use it to prove what I need.

The argument principle is based on the fact that the function $\;\frac {f'}f\;$ has a simple pole with residue $\;\eta\;$ at any zero of order $\;\eta\;$ of $\;f\;$ , and a simple pole with residue $\;-\eta\;$ at any pole of order $\;\eta\;$ of $\;f\;$ , and then the winding number and etc.
Well, the generalization is then very simple (following Ahlfors' "Complex Analysis") , since exactly the same argument as above goes for $\;g\frac{f'}f\;$ , namely: it has a simple pole of residue $\;\eta g(a)\;$ at any pole $\;a\;$ of order $\;\eta\;$ of $\;f\;$ and etc. for the poles of $\;f\;$ .