TT #104 · Parashas Shoftim · Second Aliyah · Passuk 17:17
And he must not multiply wives for himself, so that his heart not turn away; and he must not greatly multiply silver and gold for himself.
Torah Temimah points to Sifrei Devarim 159.
TT lemma: לֹא יַרְבֶּה לוֹ נָשִׁים.
English: ‘He shall not multiply wives for himself’ – so that he shall have only eighteen.
Derash fixing a numerical limit (Sifrei / Bavli) — the tradition settles on a concrete upper bound.
Traditional halakhah limits a king to eighteen wives, reading the verse as setting a practical boundary against excess.