How to calculate number of each type of atom in a residue in PyMOL? I have a 3D model of PDB 4UDC (dexamethasone bound to human glucocorticoid receptor), and I'd like to calculate how many atoms of each element are in the dexamethasone molecule (which has the residue name DEX) in this model, just to make sure it is correct (as I have added hydrogen atoms with h_add and if I missed a double bond it will be off). So how do I determine how many atoms of each element are present in this residue? 

The sort of output I'd be looking for, from whatever answer you provide, would be something like:

C22H29FO5

if I got the bond order and everything else right. Just so you know, as I would dislike it if you thought I meant if we were to count all the atoms up altogether (which would be $22+29+1+5=57$).
Not super elegant, but this should work:

select resn dex and symbol C


Pymol will respond,

Selector: selection "sele" defined with 22 atoms.


Repeat for H, F, O.