which is a lie, but still. Its on the high end of the estimations. Trump confused what’s been spent, and what is projected to be spent. That said, he’s right to note the large cost of U.S. intervention in the Middle East.
The Congressional Research Service estimated in 2014 that the Iraq and Afghanistan wars (mainly the cost of operations) had cost the United States about $1.6 trillion from 2001 to 2014.
https://fas.org/sgp/crs/natsec/RL33110.pdf
A 2016 Brown University study, for example, pinned the cost of the wars in Iraq, Afghanistan, Pakistan and Syria at about $3.6 trillion from 2001 to 2016, using the $1.6 trillion operations costs as a baseline but also accounting for counterterrorism costs.
Adding in money appropriated for war spending and on homeland security in 2017, the total reaches $4.79 trillion. This figure also includes future obligations for veterans medical and disability costs ($1 trillion through 2053) as well as interest on borrowing for wars.
If you want to talk debt, start here.