Changing animation for according to instance count

I make a barn layout and all of it’s object are grouped in the BarnGroup
Now in all the barn layout there is object BarnfoodIndicator that has two animation Empty and Food
I want to get the instance count of the object with the animation “Food” and put it in Barngroup

And the second thing is that after getting the total animal count in each barn layout and the total count of barnfoodindicator

  1. If the food is more than animals then it will randomly pick barnfoodindicator and change it’s animation to Empty
  2. it is working
  3. If animals are more than food then it will randomly pick cowgroup and change its variable