How to query users to count all with a custom capability and limit it to a set of roles?

How to query users to count all with a custom capability and limit it to a set of roles?