The American military has been pressing the Afghans to abandon that policy and not worry so much about guarding rural areas as protecting population centers. At the same time, the government and the Americans have encouraged the training of more commando forces, who would in theory have the same mobility — backed up by air power — as the insurgents.

But most deaths among the Afghan security forces continue to be those of police officers and soldiers at relatively isolated outposts, as military leaders struggle with local politicians who want their areas protected.

Does this mean the Taliban are winning?

Some people think the Taliban are indeed winning, but Mr. Ghani denied it in his speech to Johns Hopkins, as he has in other recent public remarks.

“Is the state at risk of collapse?” he said. “No. Why? Because as long as we have our commando forces and our air force, we will be able to retake. Are the losses horrific? Yes.”

Afghan officials also insist that they are giving as good as they get, and killing large numbers of Taliban militants. In fact, last year the government claimed to have killed 13,600 insurgents and arrested 2,000 more, nearly half the insurgents’ total strength, according to some estimates.

Verifying that claim is difficult; only in rare cases are the authorities able to produce bodies or photographs as evidence. That is partly because the insurgents generally try to take away their dead, and unlike government casualties, they rarely end up in hospitals or morgues.

What about American losses?

Mr. Ghani’s figure that 58 Americans have been killed since 2015 is actually on the high side. According to the special inspector’s reports, 30 American soldiers were killed in Afghanistan from 2015 to 2017. Nine more Americans have died so far this year, according to icasualties.org, which tracks war fatalities. (Mr. Ghani’s number may have included casualties from NATO and other members of the American-led coalition.)