You could do this in a Java action. Can you explain your case though? Since you define the enumerations yourself, why do you need a count?
If you know Java you can start here: https://world.mendix.com/display/refguide3/Java+Programming and follow the Java API tutorial and read the java doc to figure out the object structure.
Create a Java Action (for example EnumCount) with your enumeration (MyEnum) as input and output integer/long. Run the model once. Open the created javafile EnumCount.Java and look for
// BEGIN USER CODE return 0; // END USER CODE
// BEGIN USER CODE return (long) MyEnum.values().length; // END USER CODE
You have to make one per enumeration.