וַיִּפְקֹ֣ד דָּוִ֔ד אֶת־הָעָ֖ם אֲשֶׁ֣ר אִתּ֑וֹ וַיָּ֣שֶׂם עֲלֵיהֶ֔ם שָׂרֵ֥י אֲלָפִ֖ים וְשָׂרֵ֥י מֵאֽוֹת׃
And David numbered the people that were with him, and set captains of thousands and captains of hundreds over them.
Read midrashic interpretation of II Samuel 18:1: and classical rabbinic exegesis.