The final withdrawal of foreign troops from Afghanistan could be imminent, as the last US and Nato forces have left Bagram airbase, north of Kabul.
President Biden has said he wants US troops out of Afghanistan by 11 September this year.
We've been looking at how much the US has spent in Afghanistan since the war began.
What forces did the US send?
The US invaded Afghanistan in October 2001 to oust the Taliban, whom they said were harbouring Osama Bin Laden and other al-Qaeda figures linked to the 9/11 attacks.
US troop numbers in Afghanistan grew as Washington poured in billions of dollars to fight a Taliban insurgency and fund reconstruction.
That had gone down to 4,000 by December last year, with the numbers shrinking further this year.
Official data may not always include special operations forces, and other temporary units.
About 650 US troops are expected to remain in Afghanistan to provide security for diplomats after the main withdrawal is completed, according to the Associated Press.
And there are also significant numbers of private security contractors working for the US in Afghanistan. This included as of the last quarter of 2020 more than 7,800 US citizens, according to US Congress research.
As the US military shifted its focus away from offensive operations and concentrated more on training up Afghan forces, costs fell sharply.
Between 2010 to 2012, when the US for a time had more than 100,000 soldiers in the country, the cost of the war grew to almost $100bn a year, according to US government figures.
By 2018 annual expenditure was around $45bn, a senior Pentagon official told the US Congress that year.
According to the US Department of Defense, the total military expenditure in Afghanistan (from October 2001 until September 2019) had reached $778bn.
In addition, the US state department - along with the US Agency for International Development (USAID) and other government agencies - spent $44bn on reconstruction projects.
That brings the total cost - based on official data - to $822bn between 2001 and 2019, but it doesn't include any spending in Pakistan, which the US uses as a base for Afghan-related operations.
According to a Brown University study in 2019, which has looked at war spending in both Afghanistan and Pakistan, the US had spent around $978bn (their estimate also includes money allocated for the 2020 fiscal year).
The study notes that it is difficult to assess the overall cost because accounting methods vary between government departments, and they also change over time, leading to different overall estimates.
Where has the money gone?
The bulk of the money spent in Afghanistan has been on counter-insurgency operations, and on the needs of US troops such as food, clothing, medical care, special pay and benefits.
However, official data shows that since 2002, the US has also spent about $143.27bn on reconstruction activities in Afghanistan.
More than half ($88.32bn) was spent on building up Afghan security forces, including the Afghan National Army and police force.
Nearly $36bn has been allocated for governance and development, while smaller amounts were also allocated for anti-drug efforts and for humanitarian aid.
Some of this money has been lost to waste, fraud and abuse over the years.
In a report to the US Congress in October 2020, the watchdog responsible for the oversight of reconstruction efforts in Afghanistan estimated that about $19bn had been lost this way between May 2009 and December 31, 2019.
What about the human cost?
Since the war against the Taliban began in 2001, US forces have suffered more than 2,300 deaths and around 20,660 soldiers injured in action.
But US casualty figures are dwarfed by the loss of life among Afghan security forces and civilians.
President Ghani said in 2019 that more than 45,000 members of the Afghan security forces had been killed since he became president five years earlier.
Brown University's research in 2019 estimated the loss of life amongst the national military and police in Afghanistan to be more than 64,100 since October 2001, when the war began.