Image copyright Getty Images Image caption A firearms instructor teaching pilots in Artesia in October 2003

Thousands of US airline pilots carry guns in the cockpit. Why do they do it - and how are they trained?

Every year, hundreds of American pilots head to Artesia, New Mexico, to learn new skills.

The training lasts 56 hours, spread across five days. Up to 48 people are in each class.

They are normal pilots, working for normal airlines: Delta, for example, or United, or Southwest.

But they're not learning about new planes, or new rules. They're learning how to shoot hijackers.

Seventeen years ago, in the space of 74 minutes, four American planes were hijacked. The date was 11 September 2001.

A year later, the Arming Pilots Against Terrorism Act was passed, allowing US pilots - working for US airlines - to carry guns in the cockpit.

The first class of Federal Flight Deck Officers, as the gun-carrying pilots are known, graduated in April 2003. Classes have run ever since.

Despite that, the programme isn't widely-known. Last month, when talking about teachers having guns, President Trump said "a lot of people don't understand" that some pilots are armed.

So what are the chances of your pilot packing heat?

Image copyright Getty Images Image caption An image from the first FFDO class in April 2003

The US government does not reveal how many pilots are armed, only saying "thousands" have been trained. The names of those involved are kept secret.

The BBC spoke to one American pilot who estimates around one in 10 of the United States' 125,000 commercial pilots is armed. "Maybe less," he says.

The programme is voluntary. Training is free - as is the gun - but armed pilots aren't paid extra. Most people in Artesia take annual leave to be there.

"I've met hundreds of them," says Eric Sarandrea, deputy director of the Federal Air Marshal Service, which oversees the programme. "The first words out of my mouth are 'thank you'."

Sarandrea - who was working across the street from the World Trade Center on 9/11 - says the majority of FFDOs are, like him, ex-military (he spent four years as a US army paratrooper).

"They are patriots," he says. "They're concerned about the safety and security of their passengers. They really take it to heart."

Training begins in the classroom, before moving to a shooting range. Students learn to shoot from seating and standing positions, and prepare for hijackers trying to steal their gun.

The pilots are trained not to be drawn out of the cockpit - "They want that door bolted shut, get the aircraft on the ground," says Sarandrea - and they also learn the rules on storing the guns.

Inside the cockpit, pilots carry the guns in a hip holster. Outside, they must be transported in locked boxes.

"Their [the pilots'] authority lies within the flight deck," says the deputy director. "They can't be walking around to the stores or the malls with the firearm on their person."

Armed pilots must be in it for the long haul. After graduating in New Mexico, the FFDOs have training every six months. And, every five years, there's a two-day refresher.

All this, and not an extra cent in their wages.

"There's not much we can do for them apart from say 'thank you'," says Sarandrea. "We send them a certificate of appreciation every five years. When they retire, we give them a memento."

Image copyright Getty Images Image caption Boeing 727s at the training centre in Artesia

A US plane has not been hijacked since 9/11, so an FFDO has never used their weapon deliberately. (In 2008, a pilot shot a hole in the cockpit while trying to stow his gun ).

But globally, there have been 55 plane hijackings since 2001.

In the US, some high-risk flights - those going to risky places, or carrying passengers on watch-lists - have armed air marshals. The marshals, who have at least four months' initial training, stay in the cabin.

The armed pilots are another layer of protection, and a cheaper one. In 2013, the pilots' union Alpa said it cost the government $17 to put an FFDO on a flight - compared to $3,000 (£2,100) for a marshal .

Sarandrea says both air marshals, and armed pilots, are an important deterrent for terrorists who dream of another 9/11.

"I stay in touch with counterparts around the world, and we believe there's a cycle to it," he says. "With Isil, and Al-Qaeda, there's a fixation on aviation. For me - and it's a personal opinion - it's the crown jewel [for terrorists].

"Get on board an aircraft, take control of it, you'll be the number one terrorist organisation in the world."

Image copyright Getty Images Image caption Training at the FFDO centre in October 2003

No other countries arm their pilots, as far as Sarandrea knows, and some countries don't accept armed pilots on their territory. But most do.

"If you want to be on the visa waiver programme [allowing easier access to the US] you need an air marshal agreement in place," he says. "For the most part, we don't have a challenge."

But what about passengers who object? People who don't want guns in the cockpit? Travellers who worry about an armed pilot with mental health problems, or worse?

"The TSA [the government agency] is very strong on perpetual vetting," says Sarandrea.

"Anyone with access to aviation or transportation, there's continual vetting that goes on. And we don't just work closely with the FFDOs - we also talk to the airline.

"So if an airline says 'Hey, we have a challenge with this employee,' they know who their FFDOs are, so they will contact us.

"If there's a concern, we pull them out of the air, and we take their equipment. We do that very quickly - no matter where they are in the world."

You may also like:

The pilots' unions support the programme - the main one, Alpa, wants the government to increase funding from around $20m to $25m a year - and the courses are over-subscribed.

Bill Cason has been a pilot for more than 20 years, and is president of the Federal Flight Deck Officers Association - although, because of the programme's rules, cannot say whether he is an FFDO himself.

Cason says the volunteer officers represent "what is best in our national character". The training is rigorous, Cason says, in order "to deter, and ultimately defeat, another 9/11 style attack against the flying public and our precious cargo".

And that 74-minute period, on a September day 17 years ago, will not be forgotten soon.

"It's still something that's in the back of the pilots' mind," says Sarandrea. "They think 'I might have to be concerned with this'. And you never know."