Did you take a look at this section of the documentation?
https://docs.mendix.com/refguide/aggregate-list/
If you retrieve a list, you can count the number of items. You will probably have to add some additional logic for items that are linked to the same menu item.