MgS- Has one atom of magnesium, and 1 atom of sulfur
In this compound we have 2 atoms of sodium, 1 atom of sulphur and 4 atoms of oxygen.
Here we have 1 atom of calcium, we have 2 atoms of oxygen and 2 atoms of hydrogen. This is because if there is a small number outside the brackets you have to times it by everything inside the bracket