Calculating the amount of substance