The solution is the senior pirate distributes one coin to each priate, except the second most senior pirate gets no coins and he keeps M+2-N coins for himself.
...what is his ideal strategy? Historical precedent?
Lie to the other pirates and tell them that the magical gold coins have an invisible drawing of a new, more powerful god invisibly drawn on them?