In an action to recover the possession of real property, the plaintiff may recover damages for withholding the property, including the rents and profits or the value of the use and occupation of the property for a term not exceeding six years; but the damages shall not include the value of the use of any improvements made by the defendant or those under whom he claims. Where permanent improvements have been made in good faith by the defendant or those under whom he claims, while holding, under color of title, adversely to the plaintiff, the value thereof must be allowed to the defendant in reduction of the damages of the plaintiff, but not beyond the amount of those damages.
N.Y. Real Prop. Acts. Law § 601