(5) + auto calculating of M and N