When reading about Superficial Degrees of Divergence (SDOD) I have seen in An Introduction to Field Theory (Chapter 10.1) that for Lagrangians with a $\phi^n$ interaction term we know that:
$$\tag{1} L=P -V +1,$$ $$\tag{2} nV = N + 2P,$$
Where $L$ represents the number of loops in a diagram, $P$ the number of internal propagators, $N$ the number of external lines and $V$ the number of vertices.
The degree of divergence of the diagram is given by:
$$\tag{3}D=dL-2P.$$
Why is this so? Is there a way to derive these equations though calculations or is it just a known fact?