For those would-be investors wanting to jump into the stock market but wondering which stock to buy, legendary investor Warren Buffett has a suggestion: Try buying 500 stocks instead.

"In my view, for most people, the best thing to do is own the S&P 500 index fund," Buffett said at Berkshire Hathaway's annual meeting in May.

But what is the S&P 500, and how do you invest in one of its funds?

The Standard & Poor's 500, or S&P, is a stock market index comprised of shares of 500 large, industry-leading U.S. companies. It is widely followed and often considered a proxy for the overall health of the U.S. stock market.

Contrary to popular belief, the stocks forming the index are not the 500 biggest U.S. companies, but they are arguably the 500 most-important companies. More than $11.2 trillion is invested through the index, with these 505 stocks representing about 80% of the total U.S. stock market's value.

The S&P 500 is a cap-weighted index, meaning each stock within the index is weighted according to its market capitalization, or total market value.

As of Aug. 31, these are the top five companies by index weight: Apple, Microsoft, Amazon, Facebook and Alphabet.

You don't directly invest in the index itself.

You could buy shares in every company, but that would be an arduous task. There are, however, index funds and exchange-traded funds, or ETFs, that replicate the index, effectively doing that work for you.

There are solid options in each category, and all of these products leverage the diversity of the index itself. Some use the same market capitalization weight as the index; others equally weight the companies.

There are drawbacks to investing in the S&P 500.

The first is diversification of portfolio since the S&P consists of only large-cap U.S. stocks. Diversification decisions also should consider smaller firms, whether some funds should be in international companies and whether some funds should be in bonds, cash or other investments.

Koehler also notes drawbacks in the S&P 500 related to its market-cap weighting.

"As passive investing increases, investors are continually investing in S&P 500 funds, which has contributed to a 'rich get richer' problem, where the largest stocks are getting larger due to S&P 500 investing, rather than individual stock investing," said Kevin Koehler, a Los Angeles chartered financial analyst. "This can lead to higher volatility, as active managers sell an individual stock on top of index funds selling a portion."

Lam-Balfour is a writer at NerdWallet.