Deductions & credits

Purchase price + cost to BUY + cost to sell + improvements = cost basis

Sales price - cost basis = gross  profit  less exclusion allowed =  net taxable profit