Calculating the number of molecules and atoms