A walkthrough from one ring to a charged formula with nitrogen and halogens in it, with the calculator under every step so the sentence and the arithmetic are on the same screen.
A degree of unsaturation is rings plus pi bonds. Read it off a molecular formula, count it off a structure you draw, and compare the two: they part company whenever sulfur or phosphorus is drawn beyond the valence the formula assumes. The tool needs JavaScript; these are the pages it offers: