In this sentence, it means "first" - he took out the cost of the event (which someone says costs him "nothing" i.e. he claims it's very little) first, and then the rest went to charity.
This is typical of charity events. "Costs" are taken out, and then the rest goes to charity. A "true" charitable gesture would have been if everything - even the costs - had been donated. Then, all proceeds would have benefited the charity.
- For Teachers