So this is quite a basic counter:
It will ask you to select an object in the group and then select the drawing area.
The first selection sets the search criteria (ssget with a filter) - here searching for anything of the same entity type, on the same layer with the same colour (can add more filters later if needed).
So if you select a circle on layer "PDF_Waste_Pipe" with a colour ByLayer it will return how many of these it finds... even if there are 2 or more in that group.
Obviously it will work the best if your legend / blocks are on a unique layer - which in your sample they look like they are - and you pick an entity that only exists once in each group like a circle or rectangle.
However looking quickly at your drawing I think this might cover what you are doing I think.
I'll have a think to see if there is a more elegant way, I suspect that there is using the ssget function, crossing polylines and removing items from selection sets
(defun c:sel ( / MyEnt EntLay EntType EntCol EntClosed MySS)
(setq MyEnt (car (entsel "Select an Entity to count: ")))
(if MyEnt
(progn
(princ "Thanks. Now select the drawing area to count")
(setq EntLay (assoc 8 (entget MyEnt)))
(setq EntType (assoc 0 (entget MyEnt)))
(setq EntClosed (assoc 70 (entget MyEnt)))
(setq EntCol (assoc 62 (entget MyEnt)))
(setq SSList (list EntType EntLay ))
(if (= EntClosed nil) () (setq SSList (cons EntClosed SSList )))
(if (= EntCol nil) (setq SSList (cons (cons 62 256) SSList ))) ; colour by layer
(setq MySS (ssget SSList ))
) ; end progn
(princ "Nothing selected")
) ; end if
(princ (sslength MySS))(princ " blocks found")
(princ)
)