The "2" in the chemical formula is called a subscript . It tells you how many of that element there are.
H2O means there are 2 hydrogens and 1 oxygen.
MgCl2 means that there is 1 Magnesium and 2 Chlorine.
C6H12O6 means that there are 6 Carbons, 12 Hydrogens, and 6 Oxygens.
It's pretty self explanatory. I hope I helped