1.204 x 10 ( 24 ) atoms of magnesium are present. 
In order to go from mass of magnesium there have to do 2 things 
1. convert mass of Mg to moles of Mg using the molar mass of Mg as converted to a factor 
2. convert moles of Mg to atoms of Mg using the Avogadro's number ( 6.02 x 10  (23) as a conversion factor 
 
Hope my it helped a little :)