I want to fence in a square vegetable patch. The fencing for the east and west sides costs $8 per foot, and the fencing for the north and south sides costs only $5 per foot. Find the total cost of the fencing as a function of the length of a side x (feet).