Degree of Unsaturation(DU) of an organic compound tells us about the total number of $\pi$ bonds(both double bonds and triple bonds) and number of rings/cyclic chains in the compound.
Degree of unsaturation forms an integral part of the four tools used to identify the structure of an organic compound(some of the others being structure after hydration and ozonolysis (there's one more i don't remember)).
Wikipedia states the formula of Degree of Unsaturation as:
where C = number of carbons, H = number of hydrogens, X= number of halogens and N = number of nitrogens
A more general formula is stated as
where $n_i$ is the number of atoms with valence $v_i$
###What I'm interested is the underlying concept from which this formula is derived.