A crew of pirates robbed a Spanish galleon off the coast of Crooked Island. Among the booty they found a chest full of gold coins.
The captain was killed during the battle, so to ensure a fair share the crew decided to immediately divide up the gold coins on a nearby uninhabited island before a new captain was chosen.
The 17 surviving pirates began distributing the coins into 17 piles on the beach, but three coins were left over. No agreement could be reached as to who would get the three coins, and, after a large amount of rum was consumed, fighting followed in which one of the pirates was killed.
The pirates then divided up the coins into new piles, but, alas, this time there were as much as ten coins left. With further violent discussions, more rum and fighting another pirate was killed.
The remaining crew set about to divide the gold coins of the chest into equal piles and this time they succeeded in obtaining an equal distribution, which, after opening another barrel of rum, they celebrated until they were spread about on the beach in a drunken stupor.
It turns out they had been observed by a small Dutch crew which had been marooned on the island after a terrible storm. This crew carried away the booty and sailed off while the pirates were sleeping off the rum.
Can you work out what the least number of gold coins in the treasure chest was?