How to determine demand without the price of a good?
Consider that, if two goods are perfect substitutes, their marginal utilities are constant with respect to each other. Hence with two goods, you will consume only one or the other*.

If $\frac{a}{p_x} &gt; \frac{b}{p_y}$, then $x^*(M) = \frac{M}{p_x}; y^* = 0 $

otherwise if $\frac{a}{p_x} &lt; \frac{b}{p_y}$, then $x^* = 0; y^*(M) = \frac{M}{p_y} $

*(assume their prices are not the inverse of their marginal utilities, in which case you are indifferent).