(2) The amount of gain determined under paragraph (1) resulting from a reacquisition during any taxable year beginning after December 31, 1964, shall not exceed the amount by which the price at which the real property was sold exceeded its adjusted basis, reduced by the sum of-- (A) The amount of the gain on the sale of such property included in the measure of tax or returned as income for periods prior to the reacquisition of such property, and (B) The amount of money and the fair market value of other property (other than obligations of the purchaser received with respect to the sale of such property) paid or transferred by the seller in connection with the reacquisition of such property. For purposes of this paragraph, the price at which real property is sold is the gross sales price reduced by the selling commissions, legal fees, and other expenses incident to the sale of such property which are properly taken into account in determining gain or loss on such sale.