Suppose I have a meromorphic function $f(z)$ with poles at $f_i$ and $\mathcal{Res}(f,f_i)=1$, and $g(z)$ with poles at $g_i$ and $\mathcal{Res}(g,g_i)=1$.
I would like to construct a function $P(z)$: $$C_{f,g}(\gamma)=\oint_\gamma P(z)\,dz=\sum_{f_i=g_i\in D}1$$ where $D$ is the region bounded by $\gamma$. $P$ has only poles where both $g$ and $f$ has with residue $1$, so $C$ counts the shared poles. I have no idea how to do this, or if it is possible in general. Is there any way to construct such a $P$?
Edit:
Since $f$ and $g$ can be quite complex, I don't know a formula for the poles. I am looking forward to construct $P$ only using the definition of $f$ and $g$.
Example:
$$f(z)={1\over z-i}+{1\over z+1}+{1\over z}$$ $$g(z)={1\over z-i}+{1\over z+2}+{1\over z}$$ $$P(z)={1\over2\pi i}\left({1\over z-i}+{1\over z}\right)$$