Let's take a simple molecule, #H_2O#. By definition, all #H# nuclei have ONE positively charged particle in their nuclei (i.e. #Z=1#), and all #O# nuclei have EIGHT positively charged particle in their nuclei (i.e. #Z=8#). #Z#, #"the atomic number"#, defines the atom as a particular element: #Z=1,H#; #Z=2,He#; #Z=8,O#;....... #Z=77,Ir#; #"etc."#
The mass number represents the number of MASSIVE particles, positive and neutral, that are present in the element's nucleus. The neutral particles, so-called #"neutrons"#, participate in VERY attractive interaction at almost impossibly short nuclear distances. And different numbers of neutrons give rise to the existence of #"isotopes"#.
Most hydrogen nuclei have NO neutrons present in their nucleus; this gives the #"protium isotope," ""^1H#, which is approx. 99% abundant; a few hydrogen nuclei have ONE neutron present in their nuclei; this gives the #"deuterium isotope," ""^2H#, which is less than 1% abundant; a smaller proportion of hydrogen nuclei contain TWO neutrons; and this is the #"tritium isotope," ""^3H#.
As #Z# grows, most heavier elements have a number of stable isotopes. The #"weighted average"# of isotopic masses gives rise to the atomic masses printed on the Periodic Table. For a particular isotope, the mass number is simply the number of protons, #Z#, PLUS the number of neutrons present in that nucleus.
Anyway, you do have to have a grasp on these principles, but you don't have to remember atomic numbers, because a Periodic Table will be provided in every exam you sit in Chemistry and Physics. Good luck.