The S&P 500 (SNPINDEX: ^GSPC) has rebounded sharply from its bear market lows as concerns about runaway inflation and rising interest rates have been tempered by signs of economic resilience. This includes better-than-expected earnings in the first and second quarters. Indeed, the S&P 500 is now just 9% from a record high, putting the index on the brink of a new bull market.

That is particularly momentous because the S&P 500 returned an average of 136% during the last 14 bull markets, according to Putnam Investments, and many stocks will undoubtedly soar during the next one. Investors wondering how to capitalize on that upswing should look for trends in the quarterly Form 13Fs filed by Wall Street billionaires. Those forms detail the stocks held by institutions with at least $100 million in assets under management.  

According to the latest round of Form 13Fs, some wealthy hedge fund managers purchased shares of Amazon (AMZN 3.43%) and Mastercard (MA 0.07%) during the second quarter. That's noteworthy because both stocks also appear in Warren Buffett's portfolio through Berkshire Hathaway.

1. Amazon

Hedge fund manager Philippe Laffont doubled his stake Amazon in the second quarter, while fellow billionaire Louis Bacon quintupled his position. The stock now accounts for more than 5% of both hedge funds.

Those trades make a lot of sense, given that Amazon has solid growth prospects in e-commerce, ad tech, and cloud computing. Yet shares are currently valued at a discount to the historical average.

Amazon is the largest e-commerce company in North America and Western Europe. It powered 38.2% of online retail sales in the region last year, and that figure is expected to reach 38.7% this year. Those continued market-share gains are the result of brand authority, a powerful network effect, and substantial cost advantages arising from its logistics network, which rivals that of UPS.

Success in e-commerce has also snowballed into a sizable adtech business. Amazon recently became the third largest digital advertiser in the world, due to its ability to engage consumers and collect shopper data. Additionally, Amazon Web Services has led the cloud computing market for 12 consecutive years, an achievement that consultancy firm Gartner attributes to the unparalleled breadth and depth of its cloud services portfolio.

Amazon delivered solid financial results in the second quarter, topping expectations on the top and bottom lines. Revenue rose 11% to $134 billion, an improvement from 7% growth in the prior year, and GAAP net income was $0.65 per diluted share, up from a loss of $0.20 per diluted share in the same period last year. But the company could further accelerate growth in the coming years.

Indeed, the consensus estimate among Wall Street analysts implies revenue growth of 12% annually through 2024, and Amazon should be able to maintain a similar trajectory in the following years, given its opportunities in e-commerce, adtech, and cloud computing. That makes its current valuation of 2.6x sales look quite reasonable, and it's certainly a discount to the five-year average of 3.5x sales.

2. Mastercard

Hedge fund billionaires Steve Mandel and John Armitage both added modestly to their positions in Mastercard during the second quarter. Now, the stock represents 4% and 5% of their portfolios, respectively. That decision makes a lot of sense in the current economic environment: With inflation cooling around the world, consumer and business spending is set to rebound, and Mastercard will undoubtedly benefit.

The company operates one of the largest payments networks on the planet. Its credit and debit cards are accepted by more than 100 million merchants, and the company processed 24% of payment card purchase transactions last year. Only Visa and UnionPay handled more.

That scale underpins an important cost advantage. Mastercard has a higher profit margin than smaller competitors like American Express and Discover Financial Services because it can spread expenses over more transactions. The company can use that excess profitability to fund growth or undercut competitor pricing should they attempt to take market share.

Mastercard delivered stellar results in the second quarter. Revenue climbed 14% to $6.3 billion on strong growth in gross dollar volume and processed transactions, and GAAP earnings soared 28% to $3 per diluted share. The company should be able to maintain a similar growth trajectory for many years.

Mastercard has two important tailwinds at its back. First, the global economy tends to expand from one year to the next as consumer and business spending increases. Second, more transactions take place electronically each year as payment cards, digital wallets, and bank transfers become more popular.

Indeed, the credit card market is expected to grow at 9% annually through 2031, and the commercial virtual-card market -- an area where Mastercard has a leadership position -- is expected to grow at 12% annually through 2032. The company also has opportunities in account-based payments and value-added services.

All things considered, Mastercard has a good shot at achieving low-teens revenue growth over the next decade. That makes its current valuation of 15.9x sales look reasonable, especially in comparison to the five-year average of 18.1x sales. Investors should feel comfortable buying a small position in this growth stock today.