Atoms contain sub-atomic particles that have different charges. The atomic number of an atom is the number of protons within the nucleus of an atom. Protons have a positive charge. Once we know the number of protons in an atom, the number of electrons is also known. That is because an atom is electrically neutral and the protons and electrons balance each other out. Electrons are negatively charged particles that are located outside the nucleus in orbit around the nucleus.
The nucleus of an atom contains not only protons but neutrons. Neutrons are electrically neutral. The sum of the protons and neutrons within an atom is known as the atomic mass. Because the mass of electrons is extremely tiny, it is not calculated in this value.
In the link I have provided to the periodic table of elements, we can look up the element oxygen as an example and figure out its sub-atomic particles. It has an atomic number of 8 and an atomic mass of approximately 16. Therefore, the number of protons is 8 and the number of electrons is also 8 ( we know this from the atomic number). To find the number of neutrons, we subtract the atomic mass of 16 (number of protons plus neutrons) minus the atomic number of 8 (number of protons) to get the value of 8 neutrons.
I have included a second link to help visualize an oxygen atom to show where its sub-atomic particles are located.