The Pirates and the Gold Coins

OK, I looked at the June puzzle and it is not much of a challenge.

Doing it algebraically might be hard but algorithmically it takes a few minutes. I put my solution up here “here”).