Calculating the number of atoms in a compound