(d) Contributions to any corporation or any community chest fund or foundation organized and operated exclusively for religious, charitable, scientific, literary or educational purposes, no part of the net earnings of which inures to the benefit of any private shareholder or individual and no substantial part of the activities of which is carrying on propaganda or otherwise attempting to influence legislation. The total contributions for any calendar year shall not exceed a sum equal to one-half of one percent of the net earnings of such savings bank for the preceding calendar year. The balance thus obtained shall constitute the net earnings of the savings bank for such period.