Calculate total