Yes.
Set the trigger to activate from civilian side (animals are civilians), set the correct size for it (something like 10x10 is probably enough), set to activate repeatedly and in the condition field
this && {_x in thisList} count goats == 5
Should trigger only when the 5 goats are in.
Note that I use array stored in variable goats (goats = [goat1, goat2, etc ]) instead of writing the array manually, just to make it a bit more tidy.