(a) Corporations

In the case of a corporation, losses from sales or exchanges of capital assets shall be allowed only to the extent of gains from such sales or exchanges.

(b) Other taxpayers

In the case of a taxpayer other than a corporation, losses from sales or exchanges of capital assets shall be allowed only to the extent of the gains from such sales or exchanges, plus (if such losses exceed such gains) the lower of—

(1) $3,000 ($1,500 in the case of a married individual filing a separate return), or

(2) the excess of such losses over such gains.