Calculating the mass of compounds