Question: how do you know how many electrons an element has?
Answer: The number of electrons in a neutral atom is equal to the number of protons. The mass number of the atom (M) is equal to the sum of the number of protons and neutrons in the nucleus. The number of neutrons is equal to the difference between the mass number of the atom (M) and the atomic number (Z).