Here's a good summary of the various mortar types and their properties:
link
Either type M or S should work for your foundation wall, but S might be best. This is from the mason contractors
website:
"It should be remembered that stronger is not necessarily better when selecting mortar for unit masonry. For example, it is not typically necessary to use Type M mortar for high-strength masonry. Type S will provide comparable strength of masonry, and in fact the Masonry Standards Joint Committee's design standard ACI 530/ASCE 5/TMS 402 does not distinguish between the structural properties of masonry constructed using Type S mortar from that constructed using Type M mortar. Moreover, Type S and Type N generally have better workability, board life, and water retention. As a rule of thumb, the specifier should not require use of a mortar of higher compressive strength than necessary to meet structural design criteria."
What is that strength?
"The five typical mortar mixes designated types M,S,N,O and K are labeled so because each is an alternate letter in the term MASON WORK in descending psi strength....
M 2,500 psi
A
S 1,800 psi
O
N 750 psi
W
O 350 psi
R
K 75 psi