Calculate total amount