Count the groups of shapes