A rectangle has a length of x and a with width 3 more than twice the length. A square has a side length of 3x. If both polygons have the same perimeter what is the value of x.