Sort:  

Edit: I can proof (at least I think I can) that there is no solution for M=12 and so only M=11 and M=13 work.
And while thinking about the proof I realized that I could have solved it much easier with a little more logical thinking. If somebody wishes a short way to get the numbers I can hand it in just reply to one of my comments. BTW hope there aren't that many spelling or grammar mistakes.