Both the top and bottom numbers would have the same scale (ratio) in order to be a proportion.
Find the scale of the top numbers:
18/12 = 1.5
The top numbers have a scale of 1.5 so the bottom numbers also have a scale of 1.5
Multiply the known bottom number by the scale:
M = 34 x 1.5 = 51