Following Matthew’s stipulations, you should have counted from Babylon/JECHONIAS (NOT his son SALATHIEL) & then the total would be 14 (from ‘BABYLON unto CHRIST’).
But before I explain further, it will be quickly objected that this answer only pushes the problem back to Matthew’s previous groupings of “14”.
I will explain fully.
Your ‘problem’ should become obvious, as at the same time we dispose of the (often snarkily) repeated assertion that MATTHEW was bad at Math, because 3 times 14 equals 42, not 41 (generations Matthew names in Chapter 1).
Matthew was a TAXMAN, and we can know confidently that he never would have been hired, nor long kept his job, if he couldn’t figure 3x14=42.
So Matthew was doing something else here in verse 17.
Matthew was not making a mathematic statement, but rather making a mnemonic suggestion, a way people might begin to memorize the genealogy he records by memorizing them in 3 logical groups.
First, I presume you meant in your question to type the Greek SALATHIEL, (Matthew 1:12 “& AFTER they were brought to Babylon, Jechonias begat Salathiel; …”)) because SHEALTIEL is not mentioned in MATTHEW chapter 1.
The key is to understand that in verse 17, Matthew is recapitulating the genealogy and listing David TWICE (that is to say, in TWO of the groups of 14). And he did so to emphasize KING DAVID’s unique and monumental demarkation & status as the progenitor of the Royal line from which the Messiah must be descended.
Examine carefully Matthew 1:17 KJV:
”So all the generations from Abraham to David [are] 14 generations;
- & from David UNTIL the carrying away into Babylon [are] 14 generations;
- & from the carrying away into Babylon unto Christ [are] 14 generations."
DAVID was memorized as the final name in the first ’14 generations’ (from Abraham up to and including David),
& again memorized as the 1st of the 2nd group of 14.
Thus 3 groups of ’14’, but because DAVID IS DUPLICATED, the total is actually 41, not 42.
Look carefully: for memorization, KING DAVID is counted again as the first of the 2nd “14 generations” “until the carrying away into Babylon”. Note well that ‘until’ Babylon does not include Babylon, but rather “up until”, ie, just before.
So up UNTIL BABYLON would conclude with Josias, not Jechonias, as the final of the second 14. ((Matthew 1:10 KJV) “…& Amon begat Josias;”)
(Matthew 1:11 KJV) "And Josias begat JECHONIAS … about the TIME THEY WERE CARRIED AWAY TO BABYLON:” (Mat 1:12) "And AFTER they were brought to Babylon, Jechonias begat Salathiel; …”
In conclusion, people easily (& often intentionally) think the genealogies of the Old and New Testaments confusing. The names are strange, and often have variant spellings. Also, there is no reason to believe that any of these genealogies are all inclusive, as there is good reason to believe that they ‘skipped’ many generations and only highlighted the more significant ones.
Also, your question often leads to the next claim of ‘contradiction’, that the genealogies of MATTHEW versus LUKE differ. But, though Christians may differ, there are powerful and obvious reasons to conclude that Matthew, writing to the Hebrews, was giving the genealogy through the father Joseph, while Luke was listing that through the line of Mary.
I hope I have made this clear, and that the question of genealogies will not be an obstacle.