Thanks to the big appreciation in home prices, many homeowners are making a bundle when they sell. What's more, most will get to pocket those profits tax free -- up to $250,00 if single and up to $500,000 married -- as long as they have lived there for at least two of the past five years, courtesy of a 1997 law excluding most capital gains on principal residences from taxes. Still, a small, but growing, number of upper middle-class and affluent homeowners in pricey markets along both coasts are beginning to exceed the generous limits of the law and will have to pay capital gains taxes on the excess, according to tax and real estate experts. The tax of 15% or 5%, depending on the seller's tax bracket, can be reduced or eliminated with good tax planning and careful record keeping. For some taxpayers, the tax can even help wipe away any large, painful stock-loss carry forwards of the past several years. W.G. Spoor of Spoor Doyle & Associates CPA in St. Petersburg, Fla., says he recently worked with one client who bought a two-bedroom, two-bath condominium in Manhattan near Central Park in the late 1990s for $200,000. The man recently sold it for $700,000. "He was strictly buying in the right place at the right time," says Spoor. That was the good news. The bad news was that he made such a big profit, not all of it was tax free. The tax calculations go like this: His basis (the original price plus expenses used in calculating capital gains) in the property was the $200,000 he paid for it, plus $50,000 for remodeling the kitchen. That $250,000 was subtracted from the $700,000 sales price for a gain of $450,000. After subtracting his $250,000 capital gains exclusion for single taxpayers, the seller had $200,000 in taxable gains. For most people in this situation, those in the highest tax brackets, the capital gains rate would be 15%.