This is the list of the ancestors of Jesus Christ, a descendant of David, who was a descendant of Abraham.
a From Abraham to King David, the following ancestors are listed: Abraham, Isaac, Jacob, Judah and his brothers; then Perez and Zerah (their mother was Tamar), Hezron, Ram, Amminadab, Nahshon, Salmon, Boaz (his mother was Rahab), Obed (his mother was Ruth), Jesse, and King David.
b-11 From David to the time when the people of Israel were taken into exile in Babylon, the following ancestors are listed: David, Solomon (his mother was the woman who had been Uriah's wife), Rehoboam, Abijah, Asa, Jehoshaphat, Jehoram, Uzziah, Jotham, Ahaz, Hezekiah, Manasseh, Amon, Josiah, and Jehoiachin and his brothers. 1
References for Matthew 1:6
1.11 2 K 24.14, 15; 2 Ch 36.10; Jr 27.20.
From the time after the exile in Babylon to the birth of Jesus, the following ancestors are listed: Jehoiachin, Shealtiel, Zerubbabel, Abiud, Eliakim, Azor, Zadok, Achim, Eliud, Eleazar, Matthan, Jacob, and Joseph, who married Mary, the mother of Jesus, who was called the Messiah.
So then, there were fourteen generations from Abraham to David, and fourteen from David to the exile in Babylon, and fourteen from then to the birth of the Messiah.
This was how the birth of Jesus Christ took place. His mother Mary was engaged to Joseph, but before they were married, she found out that she was going to have a baby by the Holy Spirit. 2
References for Matthew 1:18