“The 40 days of Lent” has always been more of a metaphor than a literal count. Over the course of history the season of preparation for Easter Sunday has ranged from one day (in the first century) to 44 (today in the Roman church). Officially since 1970, Lent begins on Ash Wednesday and ends at sunset on Holy Thursday.
Already at the Council of Nicea in 325 the bishops spoke of the quadragesima paschae (Latin for “40 days before Easter”) as the well-established custom. At that time Lent began on the sixth Sunday before Easter and ended at dusk on Holy Thursday—40 days. But the council also forbade fasting, kneeling, and any other acts of sorrow and penance on Sundays, even in Lent. So only 34 of the 40 days were for fasting.
Since Jesus fasted and prayed for 40 days after his Baptism, Christians in the fifth century wanted literally 40 days of penance before Easter. The first step was to add Good Friday and Holy Saturday, the “paschal fast,” to make 36 fasting days.
The second step occurred over the course of the next few centuries in Rome. In addition to baptizing new Christians at Easter, the practice of welcoming back on Holy Thursday those who were baptized but who had committed serious sins became popular. Just as those to be baptized entered into final and intense preparation during Lent, those to be reconciled were expected to do likewise. But the first day of Lent—a Sunday—was already full, with Eucharist, a penitential procession through the city, and the rite of election for those to be baptized.
So those to be reconciled on Holy Thursday gathered on the Wednesday before the first Sunday of Lent. Wednesday (along with Friday) was already a day of fasting throughout the year, so it was appropriate to gather the penitents on that day. Borrowing a sacred sign from the scriptures, the bishop sprinkled ashes on the heads of the penitents, which they wore (without washing) until Holy Thursday as a sign of their sorrow.
This sacred sign was so attractive that even those who were not in a state of serious sin began to ask for ashes on the Wednesday before Lent. By the 11th century the pope recommended to all the bishops that ashes be distributed to anyone who sought them on that day, which became, of course, Ash Wednesday.
Here then, were four more days of fasting and penance: Ash Wednesday, Thursday, Friday, and Saturday before the first Sunday of Lent, bringing the total to 40. So today, while the season of Lent (Ash Wednesday to Holy Thursday) is technically 44 days, the number of days for penance and fasting before Easter is still 40: 44 days minus 6 Sundays equals 38, plus Good Friday and Holy Saturday equals 40.
See more at US Catholic