To quote Charles Dickens, "It was the best of times. It was the worst of times …" for Lockheed Martin (NYSE:LMT) yesterday.

On the one hand, the world's largest defense contractor lost as much as $13 billion in potential revenue when its contract to build the new Presidential Helicopter ("Marine One") was officially nixed. On the other hand, we've known that this contract was doomed for weeks. And on the third hand ...

The third hand?
Yes, bear with me. It's starting to look like Lockheed might recoup some of those losses from another defense program -- one previously considered just as dead as Marine One.

But before we get to the good news, let's start with the bad. Way back in April, when Defense Secretary Robert Gates first started taking an ax to the U.S. defense budget, one of the first projects he felled was the over-budget Marine One. Originally expected to cost "only" $6 billion, estimates to build out a 28-chopper fleet swelled to twice their original size earlier this year. "Thrifty" Gates apparently felt this was too high a price to pay to fly the president around, so the U.S. Navy made the program's cancellation official on Monday.

This means that the $3 billion Congress has already sunk into Marine One may be the last we'll see of that cash. This would be bad news for Lockheed, of course, but also for its multiple subcontractors on the project: ITT Industries (NYSE:ITT), Textron (NYSE:TXT), General Electric (NYSE:GE), and Northrop Grumman (NYSE:NOC).

(However, it might be good news for United Technolgies (NYSE:UTX), whom Lockheed's team beat out for the Marine One contract four years ago. If Lockheed's bird never gets built, that means more revenue for UTC, as the president's aging Sikorskies get a new lease on life.)

You win some, you lose some ... and then you win some back
Marine One wasn't the only high-profile casualty of Gates' ax-wielding attack; he also went all Lizzie Borden on Lockheed's much-vaunted, invisible-to-radar fighter jet, the F-22 Raptor, which Lockheed co-built with Boeing (NYSE:BA) and UTC.

At the time, I suggested that the loss of this contract might not be as bad as it sounded. While the Pentagon capped its orders at 187 F-22s total, it also accelerated its orders for Lockheed's other next-gen fighter jet, the F-35 Lightning II. Net-net, the aerospace giant appeared to be coming out of this round about even.

Now its odds have begun to look even better. Secretary Gates may think that 188 Raptors is one too many, but abroad, a lot of people are still hoping to get just one or two … squadrons, that is.

Hope springs eternal in the Land of the Rising Sun
Japan has long hoped that Congress would OK its purchase of a few F-22's for its own use. Seems there's this crazy kid in the neighborhood -- Kim Jong something-or-other -- who keeps blowing up nuclear warheads and lobbing ICBMs into the waters around Japan. Naturally, Japan feels nervous and wants a bit of extra protection. (I'm guessing Godzilla is unavailable.)

In fact, Japan would like to buy four or five dozen F-22s. And unless my calculator's on the fritz, that could work out to as much as $11.5 billion in additional revenue for Lockheed & Co. -- enough to replace the yet-unspent funds from Marine One, and then some.

The problems posed by a nuclear North Korea, combined with a willing buyer and strong ally in Japan, could be just the motivation Congress needs to keep the F-22 alive for a while yet. (According to Reuters, Senate defense subcommittee chairman Daniel Inouye is pushing to do just that.) If Congress can find a spare billion or two to buy a handful of extra F-22s, keeping production running until a Japanese sale is authorized, that might be just the ticket to replace Lockheed's lost Marine One revenues.

And if Japan gets the greenlight to buy F-22s, then why not Israel, too? Or Australia? Or even India?

Foolish takeaway
I admit, that's a pretty long string of "ifs." But if the first one falls in place for Lockheed, the odds grow increasingly good that the rest will fall like a line of dominoes. In that case, the future could look very good indeed for Lockheed.

We've got a lock on further Foolishness:

Seeking even more high-tech defense prospects for your portfolio? Check out Motley Fool Rule Breakers, where we're investigating everything from flying model airplanes, to bombproof trucks, to bulletproof soldiers. 30-day free trials are available on demand.

Fool contributor Rich Smith owns shares of Boeing. ITT is a Motley Fool Inside Value selection. The Motley Fool's disclosure policy dominates land, air, and sea.