How many unpaired electrons are in a Mg atom?

The ground state of Mg is $1 {s}^{2} 2 {s}^{2} 2 {p}^{6} 3 {s}^{2}$ so you see that the valence electrons are paired in the $3 s$ subshell. No valence electrons are unpaired here.