You can also use Atlas Search count and facets to get 1) the count of total ids and 2) the count of unique duplicateGroupId, respectively.
Atlas Search facet will return an array of distinct duplicateGroupId, which you could then calculate the length of. Make sure you define duplicateGroupId as a stringFacet field mapping to be able to perform faceting.