Buying and holding great companies can make you rich. If you invested in Amazon.com (NASDAQ: AMZN) 20 years ago in January 2001 and held it all the way, you’d have generated a return greater than 20,000%. Put another way, an investment of $5,000 will be worth more than a million dollars.

But it’s easier said than done. Not all companies are like Amazon. A study done by JP Morgan found that two-thirds of all stocks underperformed the Russell 3000 index from 1980 to 2014. Moreover, 40% of all stocks had a negative absolute return over that 30-year time frame.

And only a handful of stocks can be classified as “extreme winners” earning investors more than 500% over that time frame. So choosing the right companies to invest and hold is critical. Buying and holding lousy companies will just destroy your portfolio over time.

So what sets the best companies apart?