; and (D) but for participation in the demonstration project, would otherwise receive medical assistance for such inpatient psychiatric hospital services if the services were provided in a general acute care hospital or other residential substance abuse facility. (b) Eligible state defined (1) In general In this section, the term eligible State means a State that has made an application under paragraph (2) and has had such application approved and has been selected under paragraph (3). (2) Application A State seeking to participate in the demonstration project shall submit to the Secretary, at such time and in such format as the Secretary requires, an application that includes such information, provisions, and assurances, as the Secretary may require. (3) Selection and limitation (A) State limitation The Secretary shall limit the number of States selected for participation in the demonstration project to no more than 3 States. (B) Conditions for application approval The Secretary shall not approve an application under paragraph (2) unless the State agrees to limit participation in the demonstration project to qualifying institutions (as defined in subparagraph (C)). (C) Qualifying institution defined In this Act, the term qualifying institution means an institution for mental diseases that is not publicly owned or operated, that is subject to the requirements of section 1867 of the Social Security Act ( 42 U.S.C. 1395dd ), and that meets all of the following criteria: (i) The institution furnishes inpatient psychiatric hospital services to individuals age 18 years of age or older under the Medicare and Medicaid programs. (ii) The institution has an average length of inpatient hospital stay of less than 15 days for individuals age 18 or older, but under 65 years of age. (iii) The institution has an average length of stay of less than 21 days for hospital inpatients age 65 or older. (iv) The institution has an approved medical residency training program and receive payment due under the Medicare and Medicaid