OMAHA — “We made a mistake on the Kraft part of Kraft Heinz,” said Warren E. Buffett, chairman, president and chief executive officer of Berkshire Hathaway Inc., Omaha.

Speaking with shareholders May 4 at the Berkshire Hathaway annual meeting, Mr. Buffett was asked whether the cost-cutting approach embraced by 3G Capital will work in the food business and whether the weakened position of brands changes his view of the long-term outlook for Kraft Heinz Co.

Mr. Buffett began his response by pointing out the Berkshire Hathaway acquisition of H.J. Heinz Co. proved very successful. The problem was overpaying for Kraft.

“With the Heinz part of the transaction, we originally owned about half of Heinz, we paid an appropriate price there, and we actually did well,” he said. “We paid too much money for Kraft.”

Brazil-based 3G Capital and Berkshire Hathaway acquired Heinz in 2013 and Kraft two years later, merging the companies. Berkshire currently owns 27% of Kraft Heinz. In February, Kraft Heinz’s shares plunged after the company announced a $15.4 billion impairment charge, reflecting a downward revision in margin expectations for three Kraft businesses — Kraft natural cheese, Oscar Mayer cold cuts and Canadian retail.

Overpaying will undermine investments in even the finest company, Mr. Buffett explained at the shareholders meeting.

“We bought See’s Candy (in 1972 for $25 million), and we made a great purchase as it turned out,” he said. “We could have paid more, but there’s some price at which we could have bought even See’s Candy and it wouldn’t have worked. So the business does not know how much you paid for it.”

The growing power of private brands has been a headwind for Kraft Heinz, he said, citing the rising power of Amazon as a brand and the Kirkland brand of Costco, which has grown to $39 billion in annual sales.

“All of Kraft Heinz is $26 billion, and it’s been around for 150 years,” he said. “It has advertised billions and billions of dollars for their products. They go through tens of thousands of outlets. And there’s somebody like Costco that establishes a brand called Kirkland, and it’s doing $39 billion, more than virtually any food company. And that brand moves from product to product, which is terrific if a brand travels. I mean Coca-Cola moves it from Coke to Cherry Coke and Coke Zero and so on. But to have a brand that can really move, and Kirkland does more business than Coca-Cola does. And Kirkland operates through 775-or-so stores.”

Had Berkshire Hathaway paid less for the company, Kraft Heinz earnings would still be the same level, Mr. Buffett said.

“You can turn any investment into a bad deal by paying too much,” he said. “What you can’t do is turn any investment into a good deal by paying little.”

Asked later about 3G Capital, Mr. Buffett voiced his high regard for 3G and said the companies could be partners again in the future.

“Jorge Paulo (3G co-founder) is a good friend of mine,” Mr. Buffett said. “I think he’s a marvelous human being. And I’m pleased we are partners. It’s conceivable that something would come up. They have more of a taste for leverage than we do, and they probably have more of a taste for paying up, but in certain types of situations, they’d be way better operators than we would. I mean, they go into situations that need improvement, and they have improved them. But I think both they and we did underestimate, not what the consumer is doing so much, but what the retailer is. At See’s Candy, we sell directly to the consumer, but at Kraft Heinz, there are intermediaries. And those intermediaries are trying to make money.”

Charles T. Munger, vice-chairman of Berkshire Hathaway, sought to keep the Kraft Heinz investment in perspective.

“There’s a long series of transactions that work very well, and finally, there was one transaction at the end that didn’t work so well,” he said. “That is a very normal outcome of success.”