unless the affordable sale of such residence is during the 5-year period beginning on the date of the allocation to the qualified project of which such residence is a part (or, in the case of a qualified residence to which subsection (i) applies, the rehabilitation of such residence is completed during such 5-year period). (2) Limitations on allocations to qualified projects (A) Allocations limited by State neighborhood homes credit ceiling The aggregate amount allocated to taxpayers with respect to qualified projects by the neighborhood homes credit agency of any State for any calendar year shall not exceed the State neighborhood homes credit amount of such State for such calendar year. (B) Set-aside for certain projects involving qualified nonprofit organizations Rules similar to the rules of section 42(h)(5) shall apply for purposes of this section. (3) Determination of State neighborhood homes credit ceiling (A) In general The State neighborhood homes credit amount for a State for a calendar year is an amount equal to the sum of— (i) the greater of— (I) the product of $7, multiplied by the State population (determined in accordance with section 146(j)), or (II) $9,000,000, and (ii) any amount previously allocated to any taxpayer with respect to any qualified project by the neighborhood homes credit agency of such State which can no longer be allocated to any qualified residence because the 5-year period described in paragraph (1)(B) expires during calendar year. (B) 3-year carryforward of unused limitation The State neighborhood homes credit amount for a State for a calendar year shall be increased by the excess (if any) of the State neighborhood homes credit amount for such State for the preceding calendar year over the aggregate amount allocated by the neighborhood homes credit agency of such State during such preceding calendar year. Any amount carried forward under the preceding sentence shall not be carried past the third calendar year after the calendar year in which such credit amount originally