Get your taxes done using TurboTax

you didn't provide dates and I won't do the math for you.  however, if you had a $40K gain on A and the wash sale rules eliminate any deduction for the losses on B. your taxable income from A & B sales will only be A - $40K.