Casper's utility function is 3x + y, where x is his consumption of cocoa and y is his consumption of cheese. If the total cost of x units of cocoa is x^2, the price of cheese is $8, and Casper's income is $174, how many units of cocoa will he consume?