Rite Aid (RAD) is selling over 2,100 stores to Walgreens Boots Alliance (WBA -2.44%), and that's got investors wondering if it will be able to survive in what's become a cutthroat industry. Nevertheless, a $2.4 billion market cap seems a bit light to me, given that the company's pharmacy services segment might be worth that much alone. 

What's the deal?

Walgreens Boots Alliance had planned on buying Rite Aid lock, stock, and barrel for between $6.50 to $7 per share, but regulators objected to the combination. As a result, Walgreens Boots Alliance has exchanged plans for an outright purchase for a plan to acquire 2,186 Rite Aid stores for $5.17 billion in cash, plus a $325 million breakup fee.

A business man points at a light bulb containing a dollar sign that's floating in the air in front of him.

IMAGE SOURCE: GETTY IMAGES.

If the government green-lights this plan, Rite Aid will emerge from the transaction a lot thinner. Currently, the company has over 4,500 stores and does about $32 billion in annual sales. After it sells its stores, its revenue could conceivably fall to $17 billion.

The big drop-off in size may have you wondering if the company can compete against its much bigger rivals Walgreens Boots Alliance and CVS Health. However, a better question might be to ask what the breakup value of Rite Aid's pro forma business is.

In my view, it's a lot higher than $2.4 billion.

The company's pharmacy benefit manager (PBM) business is one big reason why I believe that Rite Aid could be undervalued. After the store sale is complete, Rite Aid will be much less reliant on its low-margin retail stores and much more reliant on its higher-margin PBM business, Envision Rx. Envision Rx helps healthcare payers save on their prescription drug costs by negotiating lower drug prices, boosting drug compliance and adherence rates, educating patients, increasing the use of low-cost generic drugs, analyzing data, and filling prescriptions via mail order.

Because PBMs eliminate waste and lower healthcare expenses for payers, the industry is a valuable tool for containing runaway drug costs. Unsurprisingly, self-insured companies and insurers are increasingly turning to companies like Envision Rx to cut costs, and that's allowing Envision Rx to be selective in the accounts it competes for.

What could Rite Aid really be worth?

Rite Aid bought Envision Rx in 2015 for $1.8 billion plus stock. At the time, Envision Rx's trailing-12-month revenue was about $4 billion. Nowadays, Envision Rx's revenue is clocking in at about a $6 annualized clip. 

Investors aren't valuing PBM sales as highly as they were a few years ago over worries that their margin could fall if the government legislates drug prices. However, even at reduced valuations, Envision Rx may be worth at least what Rite Aid's market cap is currently.

For example, over the past five years, investors have valued Express Scripts, the biggest pure-play PBM, at between 0.4 times and 0.8 times sales. If we apply those valuation levels to Envision Rx's revenue, we get a value of between $2.4 billion and $4.8 billion. If we assume the mid point, Envision Rx is worth $3.6 billion as a stand-alone company.

Even if we assume the low end is the right valuation, it could still mean that investors who buy shares today get the retail store business for free. If we apply some back-of-napkin math, we can figure out how big of a bargain that may potentially be.

Fellow Fool Keith Speights recently crunched the numbers, determining that Walgreens Boots Alliance's purchase of 2,186 Rite Aid stores values each store at $2.4 million. After the sale, Rite Aid will be left with about 2,300 stores, 60% of which have been remodeled to its Wellness format. If we assume that another buyer would pay a similar amount for Rite Aid's remaining stores -- most of which are on the east and west coasts -- then they'd have to fork over $5.4 billion. Let's say that the remaining stores are worth half what Walgreens Boots is paying. Then, they'd still be worth $2.7 billion, which is more than the company's current market cap, too.

Therefore, if you add together the low-end valuation for Envision Rx and the $2.7 billion valuation for its remaining stores, you end up with a company that's worth $5.1 billion -- or more than two times what the market is valuing it at right now.

A bargain or a bust?

Retail pharmacies are more costly to operate than pharmacy benefit managers, and as a result, Envision Rx's EBITDA margin is nearly 1% better than Rite Aid's retail store EBITDA margin. Since a shrinking store count will result in Envision Rx representing a larger proportion of the company's revenue, the company's earnings could enjoy a natural tailwind.

Furthermore, the cash windfall from Walgreen Boots Alliance is going to allow Rite Aid to pay down a big chunk of its more than $7 billion in debt, and that's going to make its interest expense fall sharply. Last quarter, the company spent more than $100 million on interest expense, and if it hadn't, it would have turned a handsome profit. Instead, it reported a loss of $75 million. If we assume that interest expense gets halved, then you'd still make big headway back toward profitability.

Of course, ultimately, what Rite Aid is worth is what investors will pay for it. There's no telling if anyone might be interested in acquiring Rite Aid, or what could happen that may reshape the profitability of its PBM business, lowering its valuation. Nevertheless, I think the risk/reward here has gotten pretty darn attractive and it might make sense for risk-tolerant investors to be buyers.