Bet against the masses. Don't be the lemming. Be fearful when others are greedy.

Follow these simple rules, and you'll probably be a successful investor.

With those rules of thumb in mind, you'd be forgiven for thinking now is a terrible time to buy stocks. The S&P 500 is up more than 50% since March, which is typically consistent with a market flooded with uncontrolled euphoria. Sure enough, many are preaching of an overvalued market that's gotten way ahead of itself.

Stand back
Maybe they're right. Sooner or later, they probably will be. But perspective is in order: When stocks bottomed out earlier this year, a better part of the investment community thought the world was destined to collapse. Companies like American Express (NYSE:AXP) and Ford (NYSE:F) traded for trivial valuations, because many people thought they were quite literally about to implode.

Today, it looks like we've skirted most of those calamitous end-of-the-world threats. Thank heavens. It's still terrible, mind you, just not as terrible as many had thought. Naturally, stocks have sprung back to levels that reflect a deep recession, rather than a total Mad Max scenario.

This is an incredibly important distinction to make: Markets haven't risen to levels that reflect exuberance, but to levels consistent with a world that isn't about to fall into mass insolvency.

This is evident by looking at the biggest winners over the past few months. By and large, the stocks that have risen the most are ones you wouldn't recommend to your worst enemy. Have a look:

Company

Return Since March

Dollar Thrifty Automotive

2,438%

Avis Budget Group

2,715%

Pier 1 Imports

3,113%

Are these companies destined for greatness? Did they announce a new blockbuster product? Are they the next Microsoft (NASDAQ:MSFT) or IBM (NASDAQ:IBM), waiting to change the way we live? Goodness, no. Not even close. Their huge gains are simply a reflection that they'll live to see another day.

In general, this is a rally built on canceling out past pessimism. The biggest gains have been concentrated in very low-quality companies that are simply being given a second shot at life. 

Not all gains are created equal 
The idea that a stock is overvalued after a massive run-up is contingent on the idea that it was properly priced to being with. But this was hardly the case when the market bottomed in March. More importantly, some of the highest-quality companies in the world have underperformed the market and still trade at attractive prices.

Here are three in particular:

Company

Return Since March

Forward P/E Ratio

Consolidated Edison (NYSE:ED)

31%

13.38

Kraft (NYSE:KFT)

23%

12.26

Wal-Mart (NYSE:WMT)

12%

13.80

What's to like about these three? Glad you asked:  

Bond guru and PIMCO head Bill Gross recently wrote, "Why not just buy utilities if that's what the future American capitalistic model is likely to resemble?" I won't argue. We've averted meltdown, but the economy is still generally wrecked, and big economic growth over the coming years, if not decades, is doubtful. That said, tried-and-true utilities that yield 5.4% -- as Consolidated Edison does -- probably won't disappoint when looked back upon 10 years from now.

Ditto for Kraft. I'd be hesitant venturing money on the return of the spend-'til-I-die-on-things-I-don't-need consumer. Cheez Whiz and crackers, I have faith in. And when you can buy a company like Kraft, with a 4.4% dividend at a very reasonable 12 times next year's earnings, you're getting a good company at a great price.

Wal-Mart hasn't rallied much since March, only because it never needed to go down much to begin with. Wal-Mart thrives on people desperate to save money, and there's been no shortage of them lately. Nor will that mentality likely change anytime soon. That's more than likely why Warren Buffett scooped up nearly 18 million shares of the company in the past quarter. 

Onward 
Perspective can be a powerful thing. Last summer, Dow 10,000 would have been associated with the end of the world. Today, some want to treat it like it symbolizes irrational exuberance, simply because we've bounced so far off the March lows. This is inherently flawed thinking. Focusing on a stock's percentage change over a short period of time is utterly meaningless. Drilling down on a company's intrinsic value, and buying the sort of bargains we haven't seen in decades, is more important.

And that's why our Motley Fool Inside Value team of analysts is having a field day digging through the rubble and finding cheap stocks like never before. To see what we're recommending today, click here for a free 30-day trial. There's no obligation to subscribe.

This article was published on June 25. It has been updated.

Fool contributor Morgan Housel doesn't own shares in any of the companies mentioned in this article. American Express, Microsoft, and Wal-Mart Stores are Motley Fool Inside Value picks. Motley Fool Options has recommended a diagonal call on Microsoft. The Fool has a disclosure policy.