Total count of open charts

 
Would someone help me with some code to return total open chart count?
 
   int count=0;
   long chartid=ChartFirst();
   
   do
     {
      chartid=ChartNext(chartid);
      count++;
     }
   while(chartid!=-1);
 
int count=0;
for(long chartid=ChartFirst(); chartid != -1; chartid=ChartNext(chartid) ) count++;
 
I really appreciate both of you, this helped immensely. 
Reason: