compute M Sum