Each square within the grid can use one fence per side.
What is the least amount of fences required to separate the goats from each other?
The goats can go anywhere, but there cannot be more than one goat per square.
You want to use as few fences as possible, so you need to make good use of the exterior fence that's already there.
To use the fewest number of fences possible, you need to divide the area into both small spaces and large spaces.
The object here is to separate each goat from the others.
Not all goats need to be enclosed within a fence.
Leave one goat outside of the fence that was already there.
Then separate the remaining four goats so that they are each in their own enclosure.
Use the left or right of the large enclosure to fence off three individual vertical squares in a row.
The answer is '5'.