Make another counter, and only increment M when this other counter reaches a specified certain amount. If you're working with frames (WAIT/VSYNC) you could count each frame. If you are working with unlocked speeds or MILLISEC then you could count time passed.