measureM function

Calculates measure M