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 60% in the past year, 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
And maybe they're right. Sooner or later, they probably will be. But perspective is in order: When stocks bottomed out last year, a better part of the investment community thought the world was about to explode. Companies like General Electric (NYSE: GE) and Capital One Financial (NYSE: COF) traded for trivial valuations because, quite literally, many thought they were about to go under.

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 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 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 2009

Dollar Thrifty Automotive

4,802%

Dana Holdings

3,925%

Avis Budget Group

2,639%

Are these companies destined for greatness? Did they announce a new blockbuster product? Are they the next Oracle (Nasdaq: ORCL), 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 last March. More importantly, some of the highest-quality companies in the world still trade at attractive prices.

Three in particular I like are Gap (NYSE: GPS), Sara Lee (NYSE: SLE), and Southern Company (NYSE: SO).

Let me tell you why.

You might laugh at Gap because its clothes feel like they're made of paper towels and you can't think of anyone who wears them. Fair point. But truth is, it's a well-run company with respectable margins that spits off a good amount of cash. Better yet, it's trading at a valuation multiple that makes it look quite cheap on a historical basis -- about seven times enterprise value to unlevered free cash flow, compared with a five-year average multiple of about 13.

After the recession wreaked havoc on consumers, name-brand goods were supposedly D.O.A. Maybe that's still the case. But when you look at the recent decline in the personal savings rate and the influx of penny-pinching consumers starting to wane from Wal-Mart's (NYSE: WMT) aisles, it makes you wonder if the death of the American consumer was blown out of proportion. Then you look at companies like Sara Lee, producer of all kinds of well-known food brands, trading at 12 times forward earnings with a 3.2% dividend, and things get interesting.

Or maybe you think we're destined for slow growth and a pitiful recovery. I'm firmly in this camp. And this isn't inconsistent with the reemergence of the consumer described above; consumer spending fell so hard in 2008-2009 that we could see a decent rebound while still suffering from an economy that can barely get moving. And if that's the case, utilities like Southern Company, with a 5.5% dividend backed by the need to turn the lights on, are probably where you want to be.

Onward 
Perspective can be a powerful thing: Two years ago, 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 last March's 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 bargains like we haven't seen in decades is what's 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, 2009. It has been updated.

Fool contributor Morgan Housel owns shares of Southern Company. Wal-Mart Stores is a Motley Fool Inside Value pick. Southern is an Income Investor choice. The Fool owns shares of Oracle. The Fool has a disclosure policy.