Suppose B has X sheep, then A has X+2 sheep;
2(X- 1)=X+2+ 1
2X-2=X+3
X=5
5+2=7
So A has seven sheep and B has five.