I am taking a guess that you mean 5 M solution instead of 5m, there is a different because M means molarity while "m" means molality.
molarity (M)= moles/ Liters
you can use this formula to solve for the moles
moles= Molarity x liters
molarity= 5 M
liters= 500mL= 0.500 L
moles= 5 x 0.500= 2.5 moles
note: if you did mean molality, let me know so I can edit the answer but it is actually the same answer.