polynomial division
X 2-2 (m+1)+m divided by X+ 1 to get an x.
The quotient of -(2m+3)X+m is another -(2m+3).
The remainder 3m+3 gives x 2-2 (m+1)+m = (x+1) (x-2m-3)+3m+3, and the remainder is 0.
Then 3m+3=0.
So m=- 1.