Warren Buffett is known for being one of the best investors of all time. If you have $300 you won't need for necessities in the next few years, it would not be a bad idea to buy a stock that the legendary investor owns. My favorite stock among Warren Buffett's Berkshire Hathaway portfolio holdings is Amazon (AMZN 1.30%)

Recently, the e-commerce retailer's stock has taken a beating because of concerns about online sales retreating as economies reopen. Still, the company has other profitable business segments that could carry the load while consumer shopping behavior recalibrates. 

A delivery person carrying boxes.

Image source: Getty Images.

Amazon is boosting operating profit margins 

In its most recent quarter ended March 31, Amazon noted that online store sales fell by 3% year over year. But that was to be expected. Sales in this segment surged by over 41% in the comparable quarter last year, so to give back some of that remarkable gain is not catastrophic. That said, it was a bit troublesome to find that shipping costs increased by 14% from last year despite the fall in sales.

Still, Amazon's more profitable web services segment is thriving. Revenue growth accelerated to 37% in Q1, up from 32% in the same quarter of the prior year. Crucially, the segment totaled 16% of revenue in Q1 but generated all of the company's operating profit. Amazon is the leading provider of cloud-based services expected to thrive over the next several years.

Another highly profitable segment that's proliferating for Amazon is advertising sales. The business has reached $32.6 billion of revenue in the trailing 12 months and has grown over 25% in each of the past six quarters. Marketers are increasingly shifting their budgets to digital channels where consumers spend more of their time and money. The trend is unlikely to reverse as digital advertising provides better measurement capability, more precision, and, therefore, a higher return on investment.

AMZN Operating Margin (Annual) Chart

AMZN Operating Margin (Annual) data by YCharts.

The faster growth in Amazon's more profitable segment has boosted the company's historically thin operating profit margin. Investors taking a holistic view of the business can see it improving over time, even if specific categories appear to be struggling. 

The market has turned sour on Amazon's stock 

The market has not taken that view. The focus has been on retreating online sales and rising costs. Amazon added hundreds of thousands of workers to support surging sales growth. Now that online sales have plateaued in the near term, the higher employee base hurts the bottom line. Too many workers might be a good problem in the current economic environment with businesses complaining of shortages. Amazon now has the luxury of slowing hiring to the very best applicants and allowing regular attrition to rightsize staffing levels.

AMZN PE Ratio Chart

AMZN PE Ratio data by YCharts.

Meanwhile, the pessimism surrounding its prospects amid changing consumer behavior has Amazon's stock down 34% off its high. It's trading at a price-to-earnings ratio of 59. In the past five years, investors have rarely had the opportunity to buy Amazon's stock at this valuation.

To put it all together, Amazon's more profitable segments are growing to take a more meaningful role in the business, boosting operating profit margins. Market worries have lowered Amazon's stock price to its lowest valuation in years. For those reasons, Amazon is the best Warren Buffett stock to buy for $300.