A square and a rectangle have equal perimeters. The length of a side of the square is 2x+1. The length of the rectangle is x+2 and the width is x. Write and solve an equation to find x