Deductions & credits

I need more of an explanation here.  So the depreciation was $15000 but the gain was $55,000 would you have to pay taxes on all $55,000 or just on the $15,000 depreciated and the $40,000 is tax free because it was a primary residence?