Losses offset gains of the same type first, then the other type, and then up to $3,000 of ordinary income.