Calculate the total amount