The circuit is a cascode amplifier. M2 has a constant voltage on its gate so it is operating as a common-gate amplifier and thus has no significant effect on Iout, which is primarily determined by M1. Thus the gain of M1 determines the gain of the circuit.
Incidentally, if the S on the top of M2 is supposed to indicate the source, that is incorrect. The top of M2 is the drain.