An M3 x 12 screw is 3mm diameter x 12 mm long. What's the pitch? The pitch also needs to be noted to make a good match. Just like SAE threads there are coarse, fine, and extra fine and so on in metric threads, stated in mm, 0.5. 0.6, 0.75 etc. In some cases the difference is so small that an incorrect pitch bolt can be screwed into another pitch hole, with resulting thread damage. So be sure of the pitch as well as the diameter and length. The proper callout would have been M3 - x.x X 12. Matching the B-40 threads to the OS ones was a lucky circumstance. Could have been disaster.
Unfortunately the bags of stuff in the hobby shops normally do not have the pitch noted, as stated be careful.