Coins count changes algorithm