When Warren Buffett buys or sells stocks, investors watch carefully. And for one good reason: The billionaire investor's track record of success. As chairman of Berkshire Hathaway, Buffett has delivered a compounded annual gain of more than 19% over 57 years, surpassing that of the S&P 500 index. The champion investor and his team have done this by choosing top quality stocks trading for reasonable prices.

In the most recent quarter, Buffett sold a number of stocks, in some cases completely closing out positions and in other cases just reducing his position. And a company on this list was one that, after years of stock market gains, completed a stock split last year.

I'm talking about e-commerce and cloud computing giant Amazon (AMZN 0.58%). Buffett didn't eliminate it from the portfolio, but instead reduced his position by 5%. Should you follow in his footsteps? 

Amazon's stock split

So, first, let's talk about the stock split. These operations, often launched following a period of gains, are done to bring down the price of each individual share -- allowing a broader range of investors to invest in the stock (without having to opt for fractional shares). A company does this by issuing more shares to current holders, so the total market value of the company remains the same.

Amazon completed such an operation after its share price soared past $3,000. Today, the stock trades at nearly $150, after a 77% gain this year. A stock split generally is a sign a company has been doing well and management expects it has what it takes to continue advancing.

Now, let's consider Amazon's recent story. The e-commerce powerhouse struggled last year amid higher interest rates -- which drove up costs and weighed on the customer's wallet. And Amazon faced some internal challenges too, like overcapacity across its newly expanded fulfillment network.

Customers flocked to Amazon earlier during the pandemic, but the economic environment that followed hurt demand. As a result, Amazon last year reported its first loss in nearly a decade.

But, the company quickly got to work, revamping its cost structure and shifting investments into its highest-growth areas, such as technology infrastructure. The efforts are bearing fruit. This year, Amazon returned to profitability, cash flow shifted to a significant inflow from an outflow, and the company grew several other key financial metrics quarter after quarter.

Recovering ROIC

In the most recent quarter, net sales climbed 13% to more than $143 billion, and net income reached almost $10 billion. Even Amazon's return on invested capital (ROIC) started to recover. And generally, it takes time for a company to see the returns on its investments, so this metric doesn't usually soar overnight.

AMZN Return on Invested Capital Chart

AMZN Return on Invested Capital data by YCharts

Amazon's new cost structure is helping the company manage through difficult times, and in a better economic environment, this structure should maximize Amazon's growth potential.

Now let's get back to Buffett's move -- and whether you should follow by either reducing your Amazon position or avoiding the shares. We don't know for sure why Buffett cut his position in Amazon, but it is important to note that he only reduced the holding by a small amount -- and he still owns 10 million shares.

This suggests the move may have been about locking in some profits and eventually reallocating the proceeds into another promising stock. And this doesn't mean Buffett or his team have lost faith in Amazon.

Should you follow Buffett?

So what should you do? If you own a considerable stake in Amazon and aim to free up some cash to invest in other stocks, you could consider selling a few shares. The stock has climbed quite a bit over time, so, like Warren Buffett, you might lock in some gains.

But in most cases, I would argue for holding on to Amazon stock. Considering the company's leadership in the two high-growth markets of e-commerce and cloud computing and its improved cost structure, Amazon has what it takes to continue growing earnings over time -- and that means the stock has plenty of fuel to power it higher over time, too.