Shares of Rite Aid Corp. (RAD 5.26%) have been hammered since its merger with Walgreen Boots Alliance (WBA -0.23%) fell apart. The stock plummeted 26% on June 29 when the news broke, and has continued slide since, giving up as much as another 24%. All told, the stock is down 44% in just two weeks.

I've taken advantage of the sell-off to add some Rite Aid shares to my personal account. While it remains a risky play, there's several reasons why I believe the pharmacy chain has significant upside potential that makes it worth the risk.

A pharmacist poses at a pharmacy counter.

Image source: Getty Images.

1. It's still making a good deal with Walgreen

Instead of Walgreen buying Rite Aid for $9 a share, the world's largest drugstore chain will buy nearly half of Rite Aid's stores at an even higher valuation. Walgreen is acquiring 2,186 of Rite Aid's 4,523 stores, or 48.3% of its base, along with three distribution centers and the inventory that goes along with it for $5.175 billion. Rite Aid will also collect a $325 million merger termination fee for the deal being blocked by Federal Trade Commission regulators. 

In other words, Rite Aid will get a total of $5.5 billion from the deal, or $2.51 million per store. That's greater than the $2.1 million its individual stores were valued at in the original acquisition agreement. In addition, Rite Aid will also be able to purchase generic drugs through a Walgreen affiliate at cost for the next 10 years. That should help shore up Rite Aid's bottom line, and improve its pharmacy margins, which have suffered in recent years. A Cowen analyst estimates Rite Aid could save 3% to 5% on its generic costs, which will be significant as generics now account for about three-quarters of U.S. prescriptions. 

2. $5.5 billion goes a long way 

Rite Aid's biggest problem right now is its substantial debt burden, at $7.2 billion as of its most recent report. The resulting interest expense from that debt has crushed profits, essentially turning Rite Aid into a breakeven business in recent years. Last year, it paid $432 million in interest, which lowered its operating income by 90%. 

If it used all of the proceeds of this new deal to pay off debt, it would reduce that burden by more than 75%, slashing annual interest expenses by more than $300 million. That's a substantial amount, considering the company's market value is just $2.4 billion. It also has more than $8 billion in tax loss carryforwards, meaning it likely won't have to pay tax on the profits it books thanks to those interest savings. Shoring up its balance sheet could also allow it to refinance its current debt, on which it's paying a weighted average interest rate of 5.4%. 

The company said it plans to use a "substantial majority" of the proceeds from the Walgreen deal to pay down debt, but will also invest some of the cash in remodeling stores.  Locations that have been remodeled with the new Wellness layout feature expanded clinical pharmacy services along with other enhancements, and the sites have outperformed the rest of the chain on both front-end comparable sales and comparable prescription count. 

3. An acquisition can still happen

Rite Aid will remain the No. 3 pharmacy chain in the U.S. after the Walgreen deal, which is expected to close by the end of the year. With more than 2,000 stores, a separate pharmacy business management benefits, and revenue around $20 billion after the sale, it will present an appealing buyout target, especially if its share price continues fall.

Possible interested parties could include competitors like Fred's (FRED), which was supposed to take over nearly 1,000 Rite Aid stores as part of the prior arrangement with Walgreen, a private-equity firm, or even Amazon.com (AMZN -1.14%), which has begun hiring people to support its own plan to expand into the pharmacy industry. Rite Aid could provide Amazon an outlet for several of its ambitions in addition to pharmacy, as its stores spread across 31 states could serve as distribution and pick-up points for Amazon, whose interest in brick-and-mortar retail is fast growing with its bookstore chain and Whole Foods acquisition.

That buyout potential should put a floor on the stock price, at the very least.

Shares of the drugstore chain have fallen to a four-year low following the renegotiated deal with Walgreen, but Rite Aid should emerge a stronger company with much less debt, improved stores, and savings on generic drugs. In its zeal to see the once-promised acquisition deal happen, the market seems to have lost sight of the underlying value in Rite Aid. I'd expect improved performance once the new deal closes.