Solution (source code)

= Solution

Let $I_b,I_f$ count internal scalar and fermion lines and $L$ count independent loops in a connected amputated <Feynman diagram>. At large <loop momentum>, the <scalar propagator> falls as $k^{-2}$ and the <Dirac propagator> falls as $k^{-1}$, including its numerator. Each loop integration is $d^3k$. The nonderivative <interaction vertices> add no powers. Therefore
$$
\omega=3L-2I_b-I_f.
$$
Count endpoints of each kind of line and use the connected-graph <loop order> identity:
$$
2I_b+b=2n_1+4n_2+6n_3,\qquad
2I_f+f=2n_1,\qquad
L=I_b+I_f-(n_1+n_2+n_3)+1.
$$
Eliminating $L,I_b,I_f$ gives
$$
\begin{aligned}
\omega&=I_b+2I_f-3(n_1+n_2+n_3)+3\\
&=\left(n_1+2n_2+3n_3-\frac b2\right)+2\left(n_1-\frac f2\right)-3(n_1+n_2+n_3)+3\\
&=\boxed{3-\frac b2-f-n_2.}
\end{aligned}
$$
The cancellation of $n_1,n_3$ reflects their dimensionless couplings; every insertion of the positive-dimensional $g_2$ improves the <superficial degree of divergence> by one.

The printed exact homogeneity is shorthand for ultraviolet <power counting>, not an identity for a massive integrated <correlation function>. For example, even the free amputated scalar two-point vertex $\Gamma^{(2)}(p)=p^2-M^2$ obeys $\Gamma^{(2)}(\lambda p)=\lambda^2p^2-M^2$, which differs from $\lambda^2\Gamma^{(2)}(p)$ when $M\ne0$. <Logarithmic divergences>, actual numerator cancellations and <ultraviolet subdivergences> also require separate treatment.