Here’s the answer & how to find it! So let us suppose,
X : the no. of sheep he owns
Y : the no. of goats he owns
Z : the no. of horses he owns
This means,
X + Y + Z = Total no. of animals he owns
He says that “They are all sheep bar three.” Which means, the no. of animals other than sheep is 3, i.e.
Y + Z = 3
Similarly,
X + Z = 4 and X + Y = 5
On adding all the three equations, we get
2 ( X + Y + Z ) = 12
This implies,
X + Y + Z = 6
This means that the farmers has a total of 6 animals. And on further solving the equations we find that the he has 3 sheep, 2 goats and a horse.