Given a Tag Path, How do we get the number of Alarm raised?

Suppose I have an integer tag with path “A\B{1}\Alarm”, and is a member of a UDT tag with path “A\B{1}” and {1} is just a number from 0 to N < 10.

And suppose I have another string tag with path “A\B{1}\AlarmPath” which basically stores the value of “A\B{1}”, How can I get the number of Alarms raised by all tags in the “A\B{1}” UDT tag?