CALCULATE TOTAL COST