Mercury has two valence electrons, both of which sit in the atom's 6s shell. A valence electron is an electron in the outermost shell of an atom. Valence electrons are capable of bonding with the valence electrons of other atoms to form a compound.
The electron configuration of mercury can be used to determine the number of valence electrons. The electron configuration is written as 1s2 2s2p6 3s2p6d10 4s2p6d10f14 5s2p6d10 6s2. The first number of each section indicates the energy level. The higher the energy level, the further the orbital is from the nucleus of the atom. In the sixth energy level, the letter s indicates the type of shell, and the number two indicates that this outermost shell contains two electrons.