When casting the Glyph of Warding spell, how many spell slots are used if you choose the Spell Glyph option?

The description of the spell states you can store a spell of 3rd level or lower by casting it as part of the Glyph of Warding.

Does this require the use of one spell slot (because you are casting it as ‘part’ of casting the glyph), or two spell slots (one for the glyph and one for the stored spell)?

Also if it does expend two spell slots, when is the second slot expended? Is it expended upon storing it? Or upon the glyph’s activation, which then casts the stored spell?