Numbering only parent comments

You can check if the comment has a parent and only count if not:

global $counter;
if ($comment->parent == 0){
  $counter++; 
}