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.