Investing

the issue is that I am selling the second building . I did not pay capital gains 20 years ago when I bought the first building because of the 1031 exchange  but now I must pay capital gains., so I need to know what my basis was when I sold the first building.  Yes, the dollar amount on the document called  relinquished property equity is sale price minus mortgage minus other sales costs.     From what I read online,  basis is calculated as purchase price minus accumulated depreciation.  But I also read online the basis should have been given to me at the time of the exchange and this relinquished equity figure is the only amount I find.  So I'm thinking maybe basis is recalculated when the 1st property is sold but I assume I still need to subtract depreciation