into account such property. (2) Overall allowance not increased No deduction shall be allowed under subsection (a) with respect to any stock for any taxable year to the extent that such deduction (when added to the deductions so allowed for all prior taxable years) exceeds the S corporation built-in gain amount with respect to such stock. (f) Recharacterization of gains as ordinary income to extent of deduction If— (1) stock of an S corporation with respect to which a deduction was allowed under this section, or (2) property which was taken into account under subsection (b)(2) with respect to such stock, is disposed of at a gain (determined without regard to whether or not such gain is recognized and reduced by any amount of gain which is treated as ordinary income under any other provision of this subtitle), the amount of such gain (or the shareholder’s pro rata share of such gain in the case of property described in paragraph (2)) shall be treated as gain which is ordinary income (and shall be recognized notwithstanding any other provision of this subtitle) to the extent of the excess of the aggregate deductions allowable under this section with respect to such stock for the taxable year of such disposition and all prior taxable years over the amounts taken into account under this subsection for all prior taxable years. (g) Termination of amortization No deduction shall be allowed under subsection (a) with respect to any stock in an electing S corporation with respect to any period beginning after the earlier of— (1) the date on which the corporation’s election under section 1362 terminates, or (2) the date on which the shareholder transfers such stock to any other person. (h) Treatment of certain transfers (1) Distributions from estates or trusts Notwithstanding any other provision of this section, in the case of a distribution of stock from an estate or trust to a beneficiary, the beneficiary (and not the estate or trust) shall be treated as the shareholder to which this section applies with respect to