For a given chemical formula represented by a string, count the number of atoms of each element contained in the molecule and return an object.