The first equation below represents dividing your flock into different parts. The second equation below is the statement that the difference between the numbers is the same as the difference of their squares.
$$a+b = S$$ $$a-b = a^2 - b^2$$
Rewrite the second equation:
$$a-b = (a-b)(a+b)$$
And, since $a \
eq b$, so that $a-b \
eq 0$, then divide $a-b$ from both sides and apply the first equation at the top of this post:
$$1 = a +b = S.$$
$S = 1$ is the number of sheep.