Check out this documentation:
https://dgraph.io/docs/query-language/count/
Although, I don’t think there is a way to count distinct of a grandchild relationship.
Yet another missing feature. There is no loop mechanism either in DQL to make this happen. You will probably have to query all of the data and then post-process it somewhere to get the counts you want on a client/middleman-server.