Two inches are cut off one side of a square board and three inches are added to an adjacent side. The resulting rectangle has a perimeter of 54 inches. What were the dimensions of the original square?