Hello I am a licensed attorney here to help you with your question, please review my response and do not hesitate to ask for clarification.
Under IRS regulations "if you exchange business or investment property solely for business or investment property of a like-kind, no gain or loss is recognized under Internal Revenue Code Section 1031. If, as part of the exchange, you also receive other (not like-kind) property or money, gain is recognized to the extent of the other property and money received, but a loss is not recognized."
If you took the profits and purchased another property with it, you would not have to pay capitol gains tax.
You would have to complete form
IRS FORM 8824