The degree of unsaturation is defined as the index of hydrogen deficiency (IHD) that determines the total number of rings and π bonds. It means the removal of two hydrogen atoms from a molecule is equal to one added DU.

[![enter image description here][1]][1]

If you add a halogen to a molecule, you need to remove a hydrogen atom (decreased half-one DU). If you do the same for a nitrogen atom, you need to remove a hydrogen atom from the molecule and add two others to the nitrogen (for amines as a saturated substituent), so you have one more hydrogen (increased half-one DU). As a result, the number of halogen and nitrogen atoms must be considered in the equation, but about other atoms such as oxygen (C-OH) and sulfur (C-SH), there is no change in the total number of hydrogen atoms when adding them as saturated substituents to a molecule.
In the case of the unsaturated substituents such as imines and carbonyls, it's clear that the total number of hydrogen atoms decreases, so the DU increases.

  [1]: https://i.sstatic.net/vTVmL.png