With the withdrawal of foreign forces from Afghanistan and the takeover by the Taliban, we've looked at how much the US and its Nato allies have spent in the country in 20 years of military operations.
What forces were sent in?
The US invaded 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 grew as Washington poured in billions of dollars to fight a Taliban insurgency and fund reconstruction, peaking at about 110,000 in 2011.
Last year, there were just 4,000 US troops.
Other countries were also part of the foreign troop presence in the country, including other members of the Nato alliance.
But the US had by far the biggest single contingent.
Nato formally ended its combat mission in December 2014, but kept a 13,000-strong force there to help train Afghan forces and support counter-terrorism operations.
There have also been significant numbers of private security contractors in Afghanistan. This included as of the last quarter of 2020 more than 7,800 US citizens, according to US Congress research.
How much money has been spent?
The vast majority of spending in Afghanistan has come from the US.
Following the final withdrawal of US troops, President Joe Biden quoted two figures for the total cost of the war.
He said: "After more than $2 trillion spent in Afghanistan... [or] you could take the number of $1tn, as many say."
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 more than $100bn a year, according to US government figures.
As the US military shifted its focus away from offensive operations and concentrated more on training up Afghan forces, costs fell sharply to about $45bn in recent years.
According to the US Department of Defense, the total military expenditure in Afghanistan (from October 2001 until December 2020) was $825bn, with about another $130bn spent on reconstruction projects.
That brings the total cost, based on official data, to about $955bn between 2001 and 2020 - close to the lower $1tn estimate given by Mr Biden.
The $2tn figure referenced by President Biden is based on a recent study by Brown University, which includes interest on debt used to finance the war and expenses such as veterans' care.
This study also includes spending in Pakistan, which the US used as a base for Afghan-related operations, and runs through to the 2022 fiscal year based on requested money.
It found that costs of the war (and future commitments) in Afghanistan from 2001 to 2022 amount to $2.3tn.
The UK and Germany - who had the largest numbers of troops in Afghanistan after the US - spent an estimated $30bn and $19bn respectively over the course of the war.
Despite pulling out nearly all their troops, the US and Nato have promised a total of $4bn a year until 2024 to fund Afghanistan's own forces.
Where has the money gone?
The bulk of the money spent in Afghanistan has been on counter-insurgency operations, and on the needs of troops such as food, clothing, medical care, special pay and benefits.
Official data shows that since 2002, the US has also spent $131.3bn on reconstruction activities in Afghanistan.
More than half 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, there have been more than 3,500 coalition deaths, of which more than 2,300 have been US soldiers.
More than 450 UK troops have died.
A further 20,660 US soldiers have been injured in action.
But these 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.
And according to the United Nations Assistance Mission in Afghanistan (Unama), nearly 111,000 civilians have been killed or injured since it began systematically recording civilian casualties in 2009.