When it was the Day of Badr and Allah's Apostle ﷺ had gained victory over them (the Meccans), he commanded more than twenty persons, and in another hadith these are counted as twenty-four persons, from the non-believers of the Quraish to be thrown into the well of Badr. The rest of the hadith is the same.
لَمَّا كَانَ يَوْمُ بَدْرٍ وَظَهَرَ عَلَيْهِمْ نَبِيُّ اللَّهِ ﷺ أَمَرَ بِبِضْعَةٍ وَعِشْرِينَ رَجُلاً وَفِي حَدِيثِ رَوْحٍ بِأَرْبَعَةٍ وَعِشْرِينَ رَجُلاً مِنْ صَنَادِيدِ قُرَيْشٍ فَأُلْقُوا فِي طَوِيٍّ مِنْ أَطْوَاءِ بَدْرٍ وَسَاقَ الْحَدِيثَ بِمَعْنَى حَدِيثِ ثَابِتٍ عَنْ أَنَسٍ