A square and rectangle have the same perimiter. The length of a side of the square is 4x-1. The length of the rectangle is 2x+2 and the width is 2x. Write and solve and equation to find x.