Nitrogen holds three bonds, so each one adds a half. Read the DBE of caffeine, C8H10N4O2. Then open the structure and split your number into rings and pi bonds.
A intermediate exercise, marked against the formula itself rather than a stored answer, with 2 hints if you want them.
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: