Shemot / Exodus 19:6 · Remez
וְאַתֶּם תִּהְיוּ־לִי מַמְלֶכֶת כֹּהֲנִים וְגוֹי קָדוֹשׁ אֵלֶּה הַדְּבָרִים אֲשֶׁר תְּדַבֵּר אֶל־בְּנֵי יִשְׂרָאֵל׃
And you shall be to Me a kingdom of kohanim and a holy nation." These are the words that you shall speak to the children of Israel.
Remez רֶמֶז
Two nations
The copyists of Tanakh counted how many times a word appears in the same form. Ba'al HaTurim gathers the places with "and a nation" (וְגוֹי) and sees two paths in them.
Ba'al HaTurim: "and a nation" (וְגוֹי) appears four times. "And a holy nation" here, "and a nation that did not know you shall run to you" in Yeshayahu (Isaiah), and twice in Yirmeyahu (Jeremiah): "and a great nation shall rise from the ends of the earth". If you are a holy nation, nations will run to you. And if not, a great nation will rise against you.
How Kitzur Ba'al HaTurim explain it
Kitzur Ba'al HaTurim And a nation
"And a nation" (וְגוֹי) appears four times: "and a holy nation", "and a nation that did not know you shall run to you" (Yeshayahu / Isaiah 55:5), and twice in Yirmeyahu about the destruction of the Temple: "and a great nation shall rise from the ends of the earth" (Yirmeyahu / Jeremiah 6:22), "and a great nation and many kings shall rise from the ends of the earth" (Yirmeyahu / Jeremiah 50:41). If you are a holy nation, "a nation that did not know you shall run to you". And if not, "a great nation shall rise".
Takeaway
This count is kept by "the copyists' count (מָסוֹרָה)": notes in the margins of scrolls on how many times and where a word appears.
In Yirmeyahu / Jeremiah 6:22 the enemy comes against Jerusalem. Yirmeyahu / Jeremiah 50:41 speaks of a people from the north who will come against Babylon. Ba'al HaTurim puts both verses side by side by one word.