Count leaves via accumulation