Counting atoms and calculating total mass