Call

There are few simple rules to follow.

(1) The is equal to the number of protons.

$Z$ = number of protons

(2) In neutrally charged , the number of electrons is the same as the number of protons.

$Z$ = number of protons = number of electrons (no charge)

Otherwise, positive charge means that the element lost an electron and negative charge means it gained an electron.

(3) The is equal to the sum of the number of protons and number of neutrons.

$A$ = number of protons + number neutrons

or

$A$ = $Z$ + number neutrons

So if you say that $Z$ = 20 and $A$ = 40, then

$A$ = $Z$ + number neutrons

40 = 20 + number of neutrons

40 - 20 = number of neutrons

Therefore,

number of neutrons = 20