Deductions & credits

the $3,000 limit is on net capital losses.   first short-term are netted. then long-term are netted.

if one type is a gain and the other is a loss they are netted. if the net is a loss up to $3,000 is allowed

 

so in your situation, you would end up with a net LTCG of $20,000