M shell means it is third shell ⇒n=3
For element X: atomic number = 18
thus its electronic configuration: 1s22s22p63s23p6
Electrons in M shell =2+6=8
For element Y: atomic number = 19
thus its electronic configuration: 1s22s22p63s23p64s1
Electrons in M shell =2+6=8
For element Z: atomic number = 20
thus its electronic configuration: 1s22s22p63s23p64s2
Electrons in M shell =2+6=8
thus in element X,Y,Z the number of electrons in M shell is 8,8,8 respectively.