If the atomic mass of a substance = M ie., the number of protons and neutrons in an atom of the substance is equal to M then,
in M grams of the substance there are Avogadro number of atoms. ie., 6.023 * 10²³ number of atoms.
It is physically not possible to count the number of atoms and molecules. It is possible to establish a relationship between the mass and number of atoms or molecules.
Molecular mass of oxygen is 32... so in 32 grams of oxygen gas - regardless of volume, temperature, pressure density etc.. there are 6.023 * 10²³ number of molecules.