The length of a rectangle is 2 inches less than three times its width, and its perimeter is 36 inches. Find the width of the rectangle.