How do we determine the number of neutrons given #Z#, and a #"mass number"#?
Well, other than by experiment, you need to know
To a first approximation, the mass of an atom, is the combined mass of the nuclear particles: (i) the protons, massive, POSITIVELY charged nuclear particles; and (ii) the neutrons, massive NEUTRALLY charged nuclear particles.
The number of nuclear protons gives
You should not have to remember these numbers, because for most every exam you do in chemistry or physics, you should be offered a Periodic Table of the known elements, of which there are 100 or so. And because most matter is neutral, for every positive charge, in the NEUTRAL atom, there should be an equal number of electrons, fundamental particles of NEGLIGIBLE mass, that are conceived to whizz about the massive nucleus at some (comparable) considerable distance.
Interaction of these electrons with other nuclei, and exchange of these electrons with other nuclei, can explain and rationalize all of chemistry, and the formation of new chemical bonds, and new substances.
So now (after explaining all of chemistry!), we finally attempt to answer your question. The nuclear core of elements CONTAINS protons, and it also contains OTHER massive particles, with ZERO electric charge, called NEUTRONS. Interactions between protons, and neutrons, is at short ranges ATTRACTIVE, and is strong enuff to overcome electrostatic repulsion between the positively charged protons.
A given nucleus of a specific element contains a given number of protons. There may be varying numbers of neutrons, and this gives rise to the phenomenon of isotopes, which are atoms of the same element, but which contain differing numbers of neutrons. Most elements exhibit a number of isotopes: for instance for the element hydrogen, mostly we have
The combined mass of the nuclear particles, the protons, and the neutrons, are to a first approximation, the mass of the element. So to finally address your question, given the element, we measure or are quoted its mass; the number of neutrons is the mass number LESS