Magnesium sulfide contains magnesium and sulfur atoms. The valence electrons in Mg are 2. The valence electrons in S are 6.