Sorry, Bob Barker and Drew Carey: The price isn't right. Inflation is at its highest level in 40 years. Nearly everything is more expensive these days, including gas, groceries, and any product that uses a microchip.

This rampant inflation is a big reason the stock market has been a dumpster fire so far in 2022. But that hasn't stopped Warren Buffett from scooping up plenty of stocks for Berkshire Hathaway's (BRK.A -0.28%) (BRK.B -0.68%) portfolio. Here's Buffett's advice on what stocks to buy when inflation is high.

Wise then and now

Buffett will turn 92 in August. He's lived through plenty of inflationary periods. One of them was in the early 1980s, when inflation rates were even higher than they are now. In 1982, Buffett wrote to Berkshire Hathaway shareholders about two characteristics that businesses should have to adapt to high-inflation environments.

First, he said that a company must have "an ability to increase prices rather easily (even when product demand is flat, and capacity is not fully utilized) without fear of significant loss of either market share or unit volume." The last part of this statement is important. Any business can increase its prices. However, doing so results in lower market share and/or unit volume in many cases because consumers choose to buy less of the companies' higher-price products.

Second, Buffett wrote that companies should possess "an ability to accommodate large dollar volume increases in business (often produced more by inflation than by real growth) with only minor additional investment of capital." In other words, inflation-resistant businesses shouldn't have to spend heavily to boost revenue.

Buffett was referring to corporate acquisitions in these comments. However, his ideas apply just as well to buying stocks. After all, buying a stock is basically just an acquisition on a small scale. The legendary investor's perspective was wise four decades ago. And it's still wise today.

Checking off the boxes

The obvious question with Buffett's advice in mind is: Which stocks meet those two criteria? It's not too hard to find stocks of companies that can satisfy one of the criteria. But there aren't many that can check off both boxes.

We only have to look at Buffett's recent investment activity to find one great example of a stock that's practically inflation-proof. In the first quarter of 2022, Berkshire initiated a position in Markel (MKL -1.17%). The specialty insurer can easily raise its premiums to adjust for inflation. Markel doesn't have to ramp up its capital spending to grow revenue, either. 

It shouldn't be surprising that Markel has trounced the overall stock market so far this year. The stock is up while the major market indexes are down significantly.

There are also stocks not among Berkshire's holdings that fulfill Buffett's criteria. Brookfield Infrastructure Partners (BIP -0.47%) (BIPC 0.32%) stands out as a good example. The company operates infrastructure assets around the world, including cell towers, data centers, pipelines, railroads, toll roads, and more. 

But do infrastructure stocks such as Brookfield Infrastructure handle high inflation well? Actually, yes. Around 70% of Brookfield Infrastructure's cash flow is indexed to inflation. While the company's growth does depend in part on investing capital in acquiring additional assets, maximizing the utilization of existing assets can also drive growth.

Brookfield Infrastructure stock has declined somewhat year to date. However, it's still outperforming the broader market. This isn't a surprise. Infrastructure stocks have historically beaten the market during high-inflation periods. 

Tale of the tapeworm

Buffett's 1982 letter to Berkshire shareholders referred to inflation as "a gigantic corporate tapeworm." He said that this tapeworm eats into companies' profits, leaving little left over for funding expansion, reducing debt, or paying dividends.

But not every business is susceptible to this inflationary tapeworm. The stocks of the ones that aren't are the best to consider buying -- if the price is right, of course.