Keep track of amount of materials needed for last community building and sell off anything above that level. A train or two will bring whatever extra is needed for the next one. I keep one of each...