The formula for ammonium nitrate is NH4NO3. One mole of ammonium nitrate contains one mole of nitrogen (N). Therefore, three moles of ammonium nitrate contain three moles of nitrogen.
$$3 moles NH_4NO_3 * \frac{1 mole N}{1 mole NH_4NO_3} = 3 moles N$$