A rectangular garden of area 408 square feet is to be surrounded on three sides by a brick wall costing $ 12 per foot and on one side by a fence costing $ 5 per foot. Find the dimensions of the garden such that the cost of the materials is minimized.