There are several ways to reconcile Lent with "40 days" - some people disregard the 6 Sundays, as every Sunday is a feast day and the day of resurrection. Others think of Lent's 40 days ending at Holy Week, which then becomes an additional week of pilgrimage with fasting.
Either way about, it's also worth remembering that the "40 days" of Jesus' stay in the wilderness was symbolic rather than literal. Here's an extract from Giving it Up:
...we know that Jesus and his disciples didn't keep all the ritual fasts of his time, but we can see from the famous story of his temptations in the wilderness that there were times when he did fast.
It's unlikely that this fast was literally 40 days long. Forty days is used symbolically throughout the biblical accounts to indicate a period of preparation and transformation. Noah's life was transformed first by 40 days of rain (Gen 7:12), and then by 40 days of waiting as his Ark rested on Ararat before he sent out a raven to search for dry land (8:6). Moses prayed for 40-day periods on Mount Sinai, the spies spent 40 days scouting out the promised land, and Elijah travelled 40 days on the strength given him by the meal that an angel brought him. David was prepared for kingship through a 40-day challenge issued by Goliath, and, when God sent Jonah to Nineveh, the city was given a period of 40 days to change its ways. Here, then, describing Jesus' fast as lasting 40 days indicates its importance as a period of preparation and transformation before embarking on his public ministry and his eventual journey to Jerusalem...