The term “unrelated trade or business” means, in the case of any organization subject to the tax imposed by section
511, any trade or business the conduct of which is not substantially related (aside from the need of such organization for income or funds or the use it makes of the profits derived) to the exercise or performance by such organization of its charitable, educational, or other purpose or function constituting the basis for its exemption under section
501 (or, in the case of an organization described in section
511
(a)(2)(B), to the exercise or performance of any purpose or function described in section
501
(c)(3)), except that such term does not include any trade or business—